This code compiles and debugs well, but when I do a maven build in Eclipse the unit test and the build fails. I don't understand where is the misuse of the matchers here? Thanks.
[ERROR] Errors: [ERROR] Tests.MyTest() » InvalidUseOfMatchers
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {MapperFactory.class})
public class Tests {
@Mock private Bucket bucketMock;
@Mock private MutateInBuilder builderMock;
@InjectMocks private Repository couchbaseRepository;
private MapperFactory mapperFactory;
@Autowired
public void setMapperFactory(MapperFactory mapperFactory) {
this.mapperFactory = mapperFactory;
}
@Test
public void MyTest() throws MyException {
String jsonText = jsonSamples.getProperty("theJson");
Mapper mapper = mapperFactory.getMapper(JsonObject.fromJson(jsonText),repository);
when(bucketMock.mutateIn("1234")).thenReturn(builderMock);
mapper.execute();
verify(builderMock).execute();
}
}
Thanks for your help, that right, that was all the exception was saying. The solution was to update the artifactId of Mockito in the pom.xml file:
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
</dependency>
was replaced with:
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
</dependency>