J'utilise le maven-surefire-plugin version 2.17 avec maven.maven-surefire-plugin, jacoco-maven-plugin ne montre aucune couverture
J'utilise jacoco-maven-plugin pour analyser mes tests JUnit:
Mon plugin jacoco mis en place dans mon pom.xml ressemble à ceci:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<executions>
<execution>
<id>agent-for-ut</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
<append>true</append>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${sonar.jacoco.reportPath}</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
J'ai une classe sous src/main/java/quelque chose/Excel qui ressemble à ceci:
package something.excel;
public class VDHTCStyle
{
public int doSomething() {
int i=0;
return i+7;
}
}
Ma classe d'essai dans src/test/java/quelque chose/Excel ressemble à ceci:
package something.excel;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class VDHTCStyleStyleTest
{
private VDHTCStyleStyle vDHTCStyleStyle;
@Before
public void setUp()
{
vDHTCStyleStyle = new VDHTCStyleStyle();
}
@Test
public void shouldDoSomething() {
int something = vDHTCStyleStyle.doSomething();
assertEquals(something, 7);
}
}
Quand je lance cela avec
mvn clean install
Je vois cela dans les journaux:
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ xxxxx ---
[INFO] Surefire report directory: /var/lib/jenkins/workspace/xxxx/modules/xx/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running something.excel.VDHTCStyleTest
|classnames | 2.2.3 | A simple utility for conditionally joining classNames together|
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.062 sec - in something.excel.VDHTCStyleTest
Maintenant, si je regarde le fichier de rapport jacoco-ut généré, je vois quelque chose comme ceci:
GROUP,PACKAGE,CLASS,INSTRUCTION_MISSED,INSTRUCTION_COVERED,BRANCH_MISSED,BRANCH_COVERED,LINE_MISSED,LINE_COVERED,COMPLEXITY_MISSED,COMPLEXITY_COVERED,METHOD_MISSED,METHOD_COVERED
Module: xxx,something.excel,VDHTCStyleStyle,9,0,0,0,3,0,2,0,2,0
Si je comprends bien, il ne pense aucune des lignes, instructions, branches ou méthodes w sont couverts.
Pourquoi? Aide :)