I am new in SonarQube.I am trying to set my first test report.
The problem is that although I have some test running successfully, I get 0 lines coverage in my Sonar report.
For example, I have a simple unittest:
@RunWith(SpringRunner.class)
@WebMvcTest(FriendController.class)
public StandaloneControllerTests
{
@MockBean
FriendService friendService;
@Autowired
MockMvc mockMvc;
and a function using Mockito
@Test
public void testCreateReadDelete() throws Exception
{
Friend("Michael","Jordan");
Arrays.asList(friend);
Mockito.when(friendService.findAll()).thenReturn(friends);
mockMvc.perform(get("/friend"))
.andExpect(status().isOk())
Matchers.hasSize(1)))
.andExpect(jsonPath("$[0].first-name", Matchers.is("Michael")));
}
I post to sonar runing:
mvn sonar:sonar -Dsonar.projectKey=my_example -Dsonar.organization=myaccount-github -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=mylogin
Any ideas?
Thank you.