0

I have a project using jacoco version 0.7.1.201405082137 and maven 3.0.5. In the project I have some unit tests, and some tests created using arquillian.

To distinguish between the unit tests and integration ones, I created two junit categories: one called FastTest and another called SlowTest.

In the maven profile that I use to run all tests I have this plugins configured:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.17</version>
    <configuration>
    <groups>SlowTest,FastTest</groups>
    <systemPropertyVariables>
        <arquillian.launch>wildfly_8_x</arquillian.launch>
    </systemPropertyVariables>
    </configuration>
</plugin>
<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>${version.jacoco}</version>
    <executions>
        <execution>
           <goals>
              <goal>prepare-agent</goal>
           </goals>
    </execution>
    <execution>
       <id>report</id>
       <phase>prepare-package</phase>
       <goals>
         <goal>report</goal>
        </goals>
    </execution>
</executions>

When I leave both categories in I get only the coverage for the tests annotated with SlowTest. But all the tests run. If I run only the ones annotated with FastTest I get their correct coverage too.

How can I set up jacoco to get the correct coverage when running both kinds of tests?

Kelly Goedert
  • 1,027
  • 2
  • 11
  • 37

1 Answers1

0

Small tip:

  • <groups> tag takes full class name. So my question: is SlowTest.class interface placed in the default package? If not you should provide full path, something like: <groups>com.mycompany.project.SlowTest</groups>

And little advice:

  • Good practice is to distinguish unit and integration tests - and thus run them separately. Maven accomplishes this by two plugins: maven-surefire-plugin and maven-failsafe-plugin.

    First is designed to run unit tests with mvn test. Second is designed to run your integration tests with mvn failsafe:integration-test. This answer may be useful to shed some light.

halfer
  • 19,824
  • 17
  • 99
  • 186
G. Demecki
  • 10,145
  • 3
  • 58
  • 58
  • Yes, the classes in have their full packages. I tried the failsafe plugin and it didn't make a difference. My unit tests use powermock, and I believe that this is the problem, since powermock has to change the classes. – Kelly Goedert Feb 10 '15 at 09:34
  • @KellyGoedert Indeed, it might be. Personally I find `PowerMock` always causing more trouble than it is worth. Really. Its hacks, like changing a classloaders can be extremely problematic. And it's only a top of the iceberg. – G. Demecki Feb 10 '15 at 09:42
  • I agree with you. Sadly for me, I cannot change the classes that make me use Powermock to test. – Kelly Goedert Feb 10 '15 at 09:45