errorcollector

How to use soft assertions in Mockito?

℡╲_俬逩灬. 提交于 2019-12-11 17:08:58
问题 I know that we can use ErrorCollector or soft assertions (AssertJ or TestNG) that do not fail a unit test immediately. How they can be used with Mockito assertions? Or if they can't, does Mockito provide any alternatives? Code sample verify(mock).isMethod1(); verify(mock, times(1)).callMethod2(any(StringBuilder.class)); verify(mock, never()).callMethod3(any(StringBuilder.class)); verify(mock, never()).callMethod4(any(String.class)); Problem In this snippet of code if a verification will fail,

Why does ErrorCollector demands for assignment at the moment of declaration?

ε祈祈猫儿з 提交于 2019-12-08 04:58:48
问题 Checkinging many XML strings, I use the ErrorCollector construction frequently. But still I do not understand how it works. When I am declaring an ErrorCollector, I have to assign it at once: @Rule public ErrorCollector collector= new ErrorCollector(); If I want to refresh the collector before every test, I am putting an assignment collector= new ErrorCollector(); in the @Before method. But thus the first assignment at the declaration is excessive. But I can't remove it. What is the sense of