Sonarqube resource not found when the UnitTest class has suffixes

Hello Sonarqube team,

I face an issue with get unit-test results export to the Sonarqube dashboard.
The issue happens when I have a test class that has a different name from the original code class name.
for example:-

  • ShiftViewModel.kt >> the original class.
  • ShiftViewModelTest.kt >> the unit-test class.

If I remove the suffixes Test from the end of the unit-test class the Sonarqube can export successfully.

I can’t remove the suffixes Test from some classes because they will be missing between the original class and test classes.

So kindly could you help me to find a way to export the unit-test result with keep unit-test have the suffixes?

@ganncamp Kindly could help me with the issue I faced

Hello,

I don’t manage to understand what you are trying to achieve at the end. :frowning: You should not have to change the names of your classes to analyze your Kotlin files with SonarQube.

If you build your project with Gradle and don’t have a special directory structure, you normally have nothing to do:

  • The “main” class will be analyzed with all the Kotlin rules
  • The “test” class will be analyzed as “test” code and so only the rules dedicated to tests will run on “test” code. Today, for Kotlin, there is 0 rule dedicated to “test” code.

Can you clarify what do you mean by “unit-test results export to the SonarQube dashboard”?

Thanks
Alex

@Alexandre_Gigleux Thank you for your help, and sorry my question was not clear
That is what I mean by “unit-test results export to the SonarQube dashboard”

Thanks for the clarification. I suggest that we continue the discussion on this thread where you provided a reproducer.

2 Likes