Kotlin tests not recognised in an Android environment

I’m running an Android project, that has most of its code and tests written in Kotlin.
Now everything is placed in src/main/java and src/test/java (as opposed to src/main/kotlin).

Sonarcloud correctly picks up all the Kotlin classes in src/main/java, but it doesn’t pick up the Kotlin unit tests in src/test/java.
I’ve added a Java unit test, and it picks it up nicely, but when I make one in Kotlin it’s not showing, not in the Code tab, nor in the Unit Tests widget on the project homepage.

My setup:

    property "sonar.sources", "src/main/java"

    property "sonar.tests", "src/test/java"

    property "sonar.junit.reportPaths", "build/test-results/testDebugUnitTest"

The XML files in testDebugUnitTest folder do present the correct XML files, so that’s generated OK.


This thread might help: Kotlin JUnit tests report is missing


Hello @Nielsz and thanks for your message.

Sorry for such a late reply. In Kotlin plugin we’re currently not visiting test files and have no rules for tests while in Java there are some rules targeting tests.

As for unit tests reports they should work because of this ticket which was recently implemented.

To make plugin recognise see your source files they should be placed in the directory specified in sonar.sources and sonar.tests.

Here you can find an example project with mixed Java and Kotlin. The gradle example will be added soon.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.