I have a project that runs two surefire executions, one with assertions enabled and one with assertions disabled. However, cobertura:cobertura appears to only run the default-test execution and skips the other one, so my assertions never get covered. How to fix this?

Attached is a minimal project that illustrates this. When the build is run normally, both surefire executions are run:

   $ mvn package
   [INFO] Scanning for projects...
   [INFO]
   [INFO]
   ------------------------------------------------------------------------
   [INFO] Building cobertura-mvn-bug 0.0.1-SNAPSHOT
   [INFO]
   ------------------------------------------------------------------------
   [INFO]
   [INFO] --- maven-resources-plugin:2.6:resources (default-resources)
   @ cobertura-mvn-bug ---
   [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
   resources, i.e. build is platform dependent!
   [INFO] skip non existing resourceDirectory
   C:\cygwin64\home\chris\cobertura-mvn-bug\src\main\resources
   [INFO]
   [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @
   cobertura-mvn-bug ---
   [INFO] Nothing to compile - all classes are up to date
   [INFO]
   [INFO] --- maven-resources-plugin:2.6:testResources
   (default-testResources) @ cobertura-mvn-bug ---
   [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
   resources, i.e. build is platform dependent!
   [INFO] skip non existing resourceDirectory
   C:\cygwin64\home\chris\cobertura-mvn-bug\src\test\resources
   [INFO]
   [INFO] --- maven-compiler-plugin:3.1:testCompile
   (default-testCompile) @ cobertura-mvn-bug ---
   [INFO] Nothing to compile - all classes are up to date
   [INFO]
   [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @
   cobertura-mvn-bug ---
   [INFO] Surefire report directory:
   C:\cygwin64\home\chris\cobertura-mvn-bug\target\surefire-reports

   -------------------------------------------------------
     T E S T S
   -------------------------------------------------------
   Running MyFunctionTest
   Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
   0.004 sec - in MyFunctionTest

   Results :

   Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

   [INFO]
   [INFO] --- maven-surefire-plugin:2.18.1:test (assertion-test) @
   cobertura-mvn-bug ---
   [INFO] Surefire report directory:
   C:\cygwin64\home\chris\cobertura-mvn-bug\target\surefire-reports

   -------------------------------------------------------
     T E S T S
   -------------------------------------------------------
   Running MyAssertionTest
   Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
   0.007 sec - in MyAssertionTest

   Results :

   Tests run: 3, Failures: 0, Errors: 0, Skipped: 0

   [INFO]
   [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @
   cobertura-mvn-bug ---
   [INFO]
   ------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO]
   ------------------------------------------------------------------------
   [INFO] Total time: 2.638 s
   [INFO] Finished at: 2015-03-05T13:01:10-05:00
   [INFO] Final Memory: 9M/174M
   [INFO]
   ------------------------------------------------------------------------


But when cobertura:cobertura is run, the second execution is skipped:

   $ mvn cobertura:cobertura
   [INFO] Scanning for projects...
   [INFO]
   [INFO]
   ------------------------------------------------------------------------
   [INFO] Building cobertura-mvn-bug 0.0.1-SNAPSHOT
   [INFO]
   ------------------------------------------------------------------------
   [INFO]
   [INFO] >>> cobertura-maven-plugin:2.7:cobertura (default-cli) >
   [cobertura]test @ cobertura-mvn-bug >>>
   [INFO]
   [INFO] --- maven-resources-plugin:2.6:resources (default-resources)
   @ cobertura-mvn-bug ---
   [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
   resources, i.e. build is platform dependent!
   [INFO] skip non existing resourceDirectory
   C:\cygwin64\home\chris\cobertura-mvn-bug\src\main\resources
   [INFO]
   [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @
   cobertura-mvn-bug ---
   [INFO] Nothing to compile - all classes are up to date
   [INFO]
   [INFO] --- cobertura-maven-plugin:2.7:instrument (default-cli) @
   cobertura-mvn-bug ---
   [INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See
   COPYRIGHT file
   [INFO] Cobertura: Loaded information on 1 classes.
   [INFO] Cobertura: Saved information on 1 classes.
   [INFO] Cobertura: Saved information on 1 classes.

   [INFO] Instrumentation was successful.
   [INFO] NOT adding cobertura ser file to attached artifacts list.
   [INFO]
   [INFO] --- maven-resources-plugin:2.6:testResources
   (default-testResources) @ cobertura-mvn-bug ---
   [WARNING] Using platform encoding (Cp1252 actually) to copy filtered
   resources, i.e. build is platform dependent!
   [INFO] skip non existing resourceDirectory
   C:\cygwin64\home\chris\cobertura-mvn-bug\src\test\resources
   [INFO]
   [INFO] --- maven-compiler-plugin:3.1:testCompile
   (default-testCompile) @ cobertura-mvn-bug ---
   [INFO] Nothing to compile - all classes are up to date
   [INFO]
   [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @
   cobertura-mvn-bug ---
   [INFO] Surefire report directory:
   C:\cygwin64\home\chris\cobertura-mvn-bug\target\surefire-reports

   -------------------------------------------------------
     T E S T S
   -------------------------------------------------------
   Running MyFunctionTest
   Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
   0.307 sec - in MyFunctionTest
   [INFO] Cobertura: Loaded information on 1 classes.
   [INFO] Cobertura: Saved information on 1 classes.

   Results :

   Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

   [INFO]
   [INFO] --- maven-surefire-plugin:2.18.1:test (assertion-test) @
   cobertura-mvn-bug ---
   [INFO] Skipping execution of surefire because it has already been
   run for this configuration
   [INFO]
   [INFO] <<< cobertura-maven-plugin:2.7:cobertura (default-cli) <
   [cobertura]test @ cobertura-mvn-bug <<<
   [INFO]
   [INFO] --- cobertura-maven-plugin:2.7:cobertura (default-cli) @
   cobertura-mvn-bug ---
   [INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See
   COPYRIGHT file
   [INFO] Cobertura: Loaded information on 1 classes.
   Report time: 184ms

   [INFO] Cobertura Report generation was successful.
   [INFO]
   ------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO]
   ------------------------------------------------------------------------
   [INFO] Total time: 6.021 s
   [INFO] Finished at: 2015-03-05T13:02:30-05:00
   [INFO] Final Memory: 14M/193M
   [INFO]
   ------------------------------------------------------------------------

Attachment: cobertura-mvn-bug.tgz
Description: Binary data

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to