I use maven and junit 4.5, mockito 1.7
If right click in the code in TestCaseA.java, select "Run as" -"Junit test" it is okay.
But if I right click parent package of TestCaseA.java, select "Run as" -"Junit test", it will fail:
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Misplaced argument matcher detected! Somewhere before this line you probably misused Mockito argument matchers.
For example you might have used anyObject() argument matcher outside of verification or stubbing. Here are examples of correct usage of argument matchers: when(mock.get(anyInt())).thenReturn(null); doThrow(new RuntimeException()).when(mock).someVoidMethod(anyObject()); verify(mock).someMethod(contains("foo")); at testCaseA.setUP(testCaseA.java:33)
public TestCaseA{
SomeService service;
@Mock
private CommonService commonService;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);***//it said this is error***
}
@Test
public void testvalidate() {
//fail even here is empty
}