maven-surefire-plugin


maven-surefire-plugin, jacoco-maven-plugin show no coverage


I am using the maven-surefire-plugin version 2.17 with maven.
I am using jacoco-maven-plugin to analyze my junit tests:
My jacoco plugin set up in my pom.xml looks like this:
<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>
I have a class under src/main/java/something/excel that looks like this:
package something.excel;
public class VDHTCStyle
{
public int doSomething() {
int i=0;
return i+7;
}
}
My test class under src/test/java/something/excel looks like this:
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);
}
}
When I run this with
mvn clean install
I see this in the logs:
[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
Now if I look at the generated jacoco-ut report file, I see something like this:
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
As I understand it, it thinks none of the lines, instructions, branches or methods were covered.
Why? Help :)
The issue seems to be that maven-surefire-plugin behaves unpredictably when specified twice in a multi module project
My parent pom had it in the build section, and the child module pom also had it in the build section. Because of that, it seemed to be running the tests, but the coverage was always 0 in the child module.
The fix was to remove maven-surefire-plugin from the child module pom, and only have it in the build section of the parent pom.
Problem sovlved.

Related Links

maven reports surefire findbugs needs flag Changes
Aggregate surefire XML reports for Sonar
Unable to invoke SureFire plugin to run a Java Test
exclude transitive dependency for maven surefire plugin
maven-surefire-plugin, jacoco-maven-plugin show no coverage
maven-surefire-report-plugin is not called during building
Maven surefire report's filename has redundant spaces when the tests are written using cucumber
maven-surefire-plugin and ReportNG cannot change stylesheet for the test report
want to modify maven surefire xhtml report in to HTML
How to format output from Maven Surefire report plugin

Categories

HOME
rust
opencart
bokeh
compilation
whmcs
out-of-memory
apk
amp
tibco
ipv6
gprs
sympy
eddystone
roku
live-streaming
dhcp
orange-api
vmware-workstation
rest-assured
social-tables
el
candlestick-chart
ini
quartz.net
react-dnd
fusetools
web-config-transform
python-appium
multi-dimensional-scaling
android-service
boolean-logic
javax.persistence
docx4j
google-play-developer-api
location-services
android-collapsingtoolbar
creation
buildforge
pdfminer
runtimeexception
cheat-engine
gitolite
stat
plane
google-prediction
bit-shift
absolute
liteide
tinyioc
knockout-2.0
beeline
nusoap
openstack-glance
solr-query-syntax
winmerge
http4s
perl-data-structures
bpms
streamwriter
visual-studio-monaco
ftp-client
android-4.2-jelly-bean
perforce-integrate
node-glob
mnesia
gravatar
ajax4jsf
textpattern
cryptojs
stack-smash
html.actionlink
calcite
enaml
360-degrees
fantom
domino-designer-eclipse
alwayson
artisan
fuseesb
python-curses
fiware-bosun
ildasm
tabris
nidaqmx
mfmessagecomposeview
miglayout
flipboard
autonumber
mft
acceptance-testing
pacman
xs
proc-open
oembed
onconfigurationchanged
server-name
firebird1.5
microblogging
fragment-identifier
upshot
photo-management
channelfactory
git-log
uninstaller
reliability
self-tracking-entities
.net-services
watchpoint
rootkit
parentid

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App