I'm running surefire tests with a jacoco agent. When I run mvn verify
a jacoco.exec
file is produced.
When I run mvn clean verify -Dtest=com.org.MyTest -DfailIfNoTests=false
then no jacoco.exec
file is produced.
Here is my surefire config.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
</configuration>
<executions>
<execution>
<phase>test</phase>
<id>testconfig</id>
<configuration>
<argLine>${test.jvm.options} ${jacoco.agent.argLine}</argLine>
<skip>false</skip>
</configuration>
<goals><goal>test</goal></goals>
</execution>
</executions>
</plugin>
Here is my jacoco config
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<configuration>
<properties>
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
<executions>
<execution>
<id>unit_agent</id>
<phase>initialize</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacoco.agent.argLine</propertyName>
</configuration>
</execution>
</executions>
</plugin>
My question is: Why no jacoco.exec produced when a single test is run - but it is produced when all tests are run?