We’ve run into another problem with the SonarQube new/updated code detection on branches.
This time, a new Java junit test was added to the project. SonarQube detected it as new/updated code, however, it is failing the quality gate saying that the unit test does 0% unit test coverage! This is a Maven project and the unit test is in src/test/java. The class file is named appropriately as *Test.java. And the unit test has junit annotations for executing the tests. The project also has a number of other junit tests exactly like this and SonarQube is not looking for unit test coverage on them.
So, any thoughts as to why SonarQube is looking for unit test coverage on a unit test?
It sounds like this is a problem not of new/overall code but of sources versus tests. Because if it’s truly being analyzed as a test, then you wouldn’t be being dinged for lack of coverage.
To test my initial hypothesis, could you provide a screenshot of the file in question in the Code tab? In particular, I’m interested to see what icon is shown to the left. E.G.
Ok so these were not set by the application but looking at the logs they are both set to the “src” directory. Which would explain Sonar’s behavior. so I thanks for the help, I think I got this answered.