Kotlin code coverage does not work

Hello, I am new to SonarCloud. I am using TravisCI with GitHub and sonarCloud to build my kotlin project and analyze the code using SonarCloud, but I have an issue regarding code coverage. I use jacoco and it works perfectly on my PC and I open the jacoco report using Intellj Coverage tool and it says that code coverage is 50%. the problem is when I push my code to GitHub. SonarCloud does not detect the coverage and it says that code coverage is 0%. Am I doing something wrong? or does not kotlin code coverage feature exist?

GitHub Repo: https://github.com/amrsamii/Kotlin-TravisCI

I see that sonarCloud finds jacoco report but it did not read it correctly as coverage is 0% while on my local machine it is 80%


Can you share the exact command you used to compile, run your tests and generate your coverage data?



here is my maven command:
./mvnw clean verify sonar:sonar -Pcoverage -Dsonar.projectKey=amrsamii_Kotlin-TravisCI

here is also SonarCloud project:

Looks like there is a problem with empty package name.
I used your reproducer, added a package name on Main.kt and now I can see the coverage data:


Finally!. it worked, thank you. but why did quality gate fail although total coverage is 66.7%?


By default, the Quality Gate is configured to fail if the Total Coverage % is lower than 80%: https://sonarcloud.io/organizations/amrsamii/quality_gates/show/9

So it’s normal to have a Failed QG, if you have a coverage at 66.7%.


FYI, here is the ticket talking about your original problem: https://jira.sonarsource.com/browse/JACOCO-10

okay I will try to avoid default package until the issue is solved :smiley: . Thank you again.