Running SonarQube Version 6.7.2 (build 37468) - LGPL v3, Junit 4 and mockito in our project, I noted that SonarQube does not recognize Mapper’s unit test and decrease the project’s percentual. In my local enviroment, the test works well and the coverage is 100% by Eclipse.
Below is the UT code:
@RunWith(MockitoJUnitRunner.class)
public class ClassMapperTest {
@Mock
private ClassMapper mapper;
@Mock
private ClassDTO dto;
@Before
public void setUp() {
mapper = Mockito.mock(ClassMapper .class);
dto = Mockito.mock(ClassDTO.class);
}
@Test
public void returnResource() {
Mockito.when(mapper.fromMethod(Mockito.anySet())).thenReturn(new HashSet<>());
mapper.fromMethod(new HashSet<ClassDTO>());
}
The statistics:
Then Commit:
Does anyone have any idea?