EasyMock matcher for class data type

我与影子孤独终老i 提交于 2019-12-01 09:35:19

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

Use a capture object instead:

Capture<Class<?>> classCapture = new Capture<Class<?>>();
EasyMock.expect(object.foo(EasyMock.capture(classCapture)));

// ... other test setup ...

Assert.assertEquals(classCapture.getValue(), String.class);

I think the following will also work as an expect statement if you don't want to use a Capture:

EasyMock.expects(object.foo(EasyMock.isA(String.class.getClass())));
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!