EasyMock matcher for class data type

后端 未结 2 767
情话喂你
情话喂你 2021-01-15 03:30

I am having nightmares with the syntax for this and easymock:

public void foo(Class clazz);

EasyMock.expects(object.foo(EasyMock.isA(???)));
         


        
2条回答
  •  一整个雨季
    2021-01-15 04:07

    You're attempting to verify a generic type that will be erased at runtime anyway.

    Use a capture object instead:

    Capture> classCapture = new Capture>();
    EasyMock.expect(object.foo(EasyMock.capture(classCapture)));
    
    // ... other test setup ...
    
    Assert.assertEquals(classCapture.getValue(), String.class);
    

提交回复
热议问题