-
Languages of the repository
JAVA -
Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
SonarCloud complains about TestCases not having a test, even though there are testNG-Test annotated methods if those are not marked public, which is technically not necessary
Hi,
Welcome to the community!
Is this Java?
Ann
Hi. Yes it is Java with TestNG. The Test Annotation is enough for TestNG to find test methods, whereas SonarCloud suggests to add Tests. This behavior changes, if the Test Annotated methods have the public modifier, even though for TestNG this is not necessary.
Thanks! I’ve flagged this for the relevant folks.
Ann
Hi Uwe, thank you for reporting, indeed the check implementing rule S2187, is mistakenly expecting the public modifier on the test method you provided, also, it seems like if you for example remove the @Test(groups = "unitTests")
annotation from the class, the check will not report any issue because is still supporting the TestNG library annotations for the methods inside a test class.
I have created a ticket to fix this, and we will work on it as soon as we can,
Leonardo
Great news! The ticket has been implemented, and now we should correctly detect test methods annotated with @org.testng.annotations.Test
. This update should be soon available on SonarQube for Cloud and released with SonarQube Server 10.9.