Test coverage 0% using Spring-boot-starter-test

(Fotis Tsakiroglou) #1

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:

public StandaloneControllerTests
FriendService friendService;

MockMvc mockMvc;

and a function using Mockito

public void testCreateReadDelete() throws Exception


.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.

(Evgeny Mandrikov) #2

(Fotis Tsakiroglou) #3

I see.
Thank you very much.
Indeed I had to add Jacoco plugin into my project.
Then running mvn test, created a report and uploaded in SonarQube account.