0

I am using Jenkins with Sonar to perform a build of my Java EE application through an ANT script.

The build works fine and the unit test case run fine as well.

I am currently getting a unit test coverage % but the "Unit test sucess" shows as zero. When I click on the "0 tests" which is available to me as a link on the Sonar dashboard, I get to see the different modules of my Java EE application which Sonar ran through as defined in the build.xml used by Jenkins.

After some research online and reading through a similar Stackoverflow question at this link - Unit test success reported as zero by Sonar

I added the following property tags in my build.xml (used by Jenkins) located in my Java EE application root folder and in the sonar.xml files residing in every sub folder which is defined as a module in the build.xml file:

<property name="sonar.java.coveragePlugin" value="jacoco" />
<property name="sonar.junit.reportsPath" value="ABCD/testreport/" />
<property name="sonar.jacoco.reportPath" value="ABCD/build/classes/jacoco.exec" />

where "ABCD" is the directory which I use to house my Junit test case JAVA files.

The ANT script xml file does contain a junit task which compiles executes my unit test cases in the Jenkins build before giving the hanndle to Sonar. Since I know I am getting a unit test coverage, I know these unit tests are being seen to a degree but what additional steps do I need to take to make the unit test success show up with a value greater than zero?

Please advise.

Thanks in advance.

Subbu

Community
  • 1
  • 1
Subbu
  • 839
  • 2
  • 12
  • 34
  • Are you generating unit tests reports? Maybe not the same with Ant however when using Maven and the surefire plugin it generates XML reports for each test under /target/surefire-reports . Sonar can then analysis these reports to determine coverage etc. – cdugga Feb 08 '14 at 02:44
  • Have you correctly specified "sonar.tests" property? – Fabrice - SonarSource Team Feb 10 '14 at 12:31
  • Hi Guys. Thanks for your reply. I have specified "sonar.tests" to point to the unit test case source directory, as per my understanding. After creating the jacoco.exec file, I do make sure it exists in "target" directories of the solution. I am getting unit test case code coverage but the "Unit test success" value is still showing as zero. I have tried everything I possibly can at this point. When I peruse through the Jenkins logs, I see this: Sensor JacocoSensor... Analyzige "F:\workspace\....\jacoco.exec"...No information about coverage per test. – Subbu Feb 10 '14 at 16:26
  • I am generating xml based Junit reports and have set the "sonar.junit.reportsPath" property to point to that folder. Still no success in Sonar updating the "unit test sucess" value from zero. – Subbu Feb 10 '14 at 19:10

0 Answers0