SonarQube
  1. SonarQube
  2. SONAR-1455

0% code coverage reported with maven-surefire-plugin 2.5

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0.1
    • Fix Version/s: None
    • Component/s: Maven Plugin
    • Labels:
      None
    • Environment:
      Windows XP 2002 SP 3
    • Number of attachments :
      0

      Description

      I'm using maven-surefire-plugin (2.5) and cobertura-maven-plugin (2.3). When I run "mvn clean sonar:sonar" at the command line I can see that unit tests are run successfully, but in the Sonar dashboard the coverage is reported as 0%. If I remove the maven-surefire-plugin from my pom and try again, the Sonar dashboard displays the expected non-zero amount of code coverage. This is happening with Sonar 2.0.1, but it also was a problem with Sonar 1.11.1.

        Issue Links

          Activity

          Hide
          Freddy Mallet added a comment -

          We've faced such issue only when Cobertura Maven Plugin version 2.2 was used. Could you double-check the version of this plugin ?
          thanks

          Show
          Freddy Mallet added a comment - We've faced such issue only when Cobertura Maven Plugin version 2.2 was used. Could you double-check the version of this plugin ? thanks
          Hide
          Matthew Shostak added a comment -

          We have definitely specified 2.3 in our pom:

          <artifactId>cobertura-maven-plugin</artifactId>
          <version>2.3</version>

          Could Sonar somehow be overriding this?

          Matt

          Show
          Matthew Shostak added a comment - We have definitely specified 2.3 in our pom: <artifactId>cobertura-maven-plugin</artifactId> <version>2.3</version> Could Sonar somehow be overriding this? Matt
          Hide
          Freddy Mallet added a comment -

          Matt, could you provide the file target/sonar/sonar-pom.xml which is generated by Sonar in the Maven target directory ?
          Thanks
          Freddy

          Show
          Freddy Mallet added a comment - Matt, could you provide the file target/sonar/sonar-pom.xml which is generated by Sonar in the Maven target directory ? Thanks Freddy
          Hide
          Matthew Shostak added a comment -

          I would if I could, but the parent project is 'multi-module' and doesn't produce a target directory.

          Show
          Matthew Shostak added a comment - I would if I could, but the parent project is 'multi-module' and doesn't produce a target directory.
          Hide
          Olivier Gaudin added a comment -

          Matt, when you say it reports zero, is it at project's level ? Module ? Both ?

          Show
          Olivier Gaudin added a comment - Matt, when you say it reports zero, is it at project's level ? Module ? Both ?
          Hide
          Matthew Shostak added a comment -

          Olivier, it shows zero at all levels.

          Show
          Matthew Shostak added a comment - Olivier, it shows zero at all levels.
          Hide
          Olivier Gaudin added a comment -

          Can you send sonar-pom.xml for one of the module ?

          Show
          Olivier Gaudin added a comment - Can you send sonar-pom.xml for one of the module ?
          Hide
          Matthew Shostak added a comment -

          We don't seem to have any file named "sonar-pom.xml" for this build.

          Show
          Matthew Shostak added a comment - We don't seem to have any file named "sonar-pom.xml" for this build.
          Hide
          Freddy Mallet added a comment -

          Hi Matthew, we do need this target/sonar/sonar-pom.xml file to figure out what happens and this file is always generated by Sonar in the target directory of each Maven project/module.

          Thanks

          Show
          Freddy Mallet added a comment - Hi Matthew, we do need this target/sonar/sonar-pom.xml file to figure out what happens and this file is always generated by Sonar in the target directory of each Maven project/module. Thanks
          Hide
          Matthew Shostak added a comment -

          Is it possible that the lack of such files is symptomatic of a problem?

          Show
          Matthew Shostak added a comment - Is it possible that the lack of such files is symptomatic of a problem?
          Hide
          Freddy Mallet added a comment -

          Hi Matthew, according to your first description, when you remove the maven-surefire-plugin section from your pom, the problem vanishes. Could you provide the content of this section ? thanks !

          Show
          Freddy Mallet added a comment - Hi Matthew, according to your first description, when you remove the maven-surefire-plugin section from your pom, the problem vanishes. Could you provide the content of this section ? thanks !
          Hide
          Matthew Shostak added a comment -

          Freddy, today we discovered that if <forkMode>never</forkMode> for the maven-surefire-plugin, we got zero percent coverage reported, even though tests ran. However, if we changed it to <<forkMode>pertest</forkMode>, then Sonar reported the code coverage numbers we were expecting. Similarly for the default (once), the code coverage numbers are what we expect. So it seems to be only with the forkMode set to never that we experience a problem.

          ,

          Show
          Matthew Shostak added a comment - Freddy, today we discovered that if <forkMode>never</forkMode> for the maven-surefire-plugin, we got zero percent coverage reported, even though tests ran. However, if we changed it to <<forkMode>pertest</forkMode>, then Sonar reported the code coverage numbers we were expecting. Similarly for the default (once), the code coverage numbers are what we expect. So it seems to be only with the forkMode set to never that we experience a problem. ,
          Hide
          Freddy Mallet added a comment -

          Thanks Matthew, I've added a new section in the Sonar FAQ. I'm going to close "won't fix" this issue as nothing can be done on Sonar side except referencing this Maven Cobertura plugin's behavior.

          Show
          Freddy Mallet added a comment - Thanks Matthew, I've added a new section in the Sonar FAQ . I'm going to close "won't fix" this issue as nothing can be done on Sonar side except referencing this Maven Cobertura plugin's behavior.

            People

            • Assignee:
              Freddy Mallet
              Reporter:
              Matthew Shostak
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: