We developed Android App written in Kotlin, Kotlin unit-test classes are not export to Sonarqube dashboard, but for Java unit-test classes work well and export to Sonarqube unit-test
The sonarqube plugin has not found the kotlin classes although they exists - full error message on the bottom.
Please advise what we should do? if there is any document or article kindly share it with us.
> Task :app:sonarqube
Resource not found: android.example.com.changelanguge.AppTest under the directory /Users/ahmedqamar/StudioProjects/ChangeLanguge/app while reading test reports. Please, make sure your "sonar.junit.reportPaths" property is configured properly
Resource not found: android.example.com.changelanguge.MainActivityTest under the directory /Users/ahmedqamar/StudioProjects/ChangeLanguge/app while reading test reports. Please, make sure your "sonar.junit.reportPaths" property is configured properly
Resource not found: android.example.com.changelanguge.ExampleUnitTest under the directory /Users/ahmedqamar/StudioProjects/ChangeLanguge/app while reading test reports. Please, make sure your "sonar.junit.reportPaths" property is configured properly
I took your reproducer and changed this in the config:
remove the SonarQube configuration from the app/build.gradle file
put the SonarQube config in the top level build.gradle file like this
plugins {
id "org.sonarqube" version "3.3"
}
sonarqube {
properties {
property "sonar.projectKey", "ahmed_unit_test_sonar"
property "sonar.junit.reportPaths", "${project.projectDir}/app/build/test-results/testDebugUnitTest"
}
}
Then I executed this command:
./gradlew test sonarqube -Dsonar.projectKey=ahmed_unit_test_sonar -Dsonar.host.url=https://changeme -Dsonar.login=changeme -i*
In the logs, I have the same weird message like you:
Sensor KotlinSurefireSensor [kotlin]
parsing [/home/alex/Repos/Android_Validation/Kotlin/ahmed_unit_test_sonar/app/build/test-results/testDebugUnitTest]
Searching for android/example/com/changelanguge/AppTest
Resource not found: android.example.com.changelanguge.AppTest under the directory /home/alex/Repos/Android_Validation/Kotlin/ahmed_unit_test_sonar/app while reading test reports. Please, make sure your "sonar.junit.reportPaths" property is configured properly
Searching for android/example/com/changelanguge/MainActivityTest
Searching for android/example/com/changelanguge/ExampleUnitTest
I don’t deny that there is a problem somewhere in KotlinSurefireSensor, still at the end, on SonarQube I see that there are 3 Tests as expected:
Hi Alex,
I found the issue that prevents unit tests from shows on SonarQube
The issue was the name of the unit test class was different from an original class name, because when creating the unit-test class it’s added by default suffix *Test word.
FeatureLogic.kt >>> the original class
FeatureLogicTest.kt >>> the test class it’s finish with suffix *Test
Is there any way to make KotlinSurefireSensor see FeatureLogicTest as a test class for FeatureLogic ?.