clover.xml does not contain code coverage for failing test case

Hi all,

I have an example project, which contains 6 test cases: 5 passing and 1 failing. I does not found how to create per-test case report and because of that I have executed following command for every test case:

mvn clean clover:setup test -Dtest=%TEST_NAME%;
mvn clover:aggregate clover:clover;

It works fine for all test, but the failing test report does not contain a code coverage (count is always zero). When the failing test case is executed together with passing test case, the report is correct.

pom.xml:

<plugin>
<groupId>org.openclover</groupId>
<artifactId>clover-maven-plugin</artifactId>
<version>4.2.0</version>
<configuration>
<generatePdf>false</generatePdf>
<generateXml>true</generateXml>
<generateHtml>true</generateHtml>
<generateJson>false</generateJson>
</configuration>
<executions>
<execution>
<phase>pre-site</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
</executions>
</plugin>

1. Is it expected behaviour?

2. Does it exist some another solution to generate for every test case a new report file with code coverage? Maybe it is possible to access the clover.db using some standard library in python/java/whatever?

Best regards

1 answer

0 votes

Hello,

 

The per-test coverage in simple builds is enabled when test sources are instrumented. This can be achieved by setting  includesTestSourceRoots=true, it's enabled by default so I suppose either you've turned it off or tests are in some different module. 

For more complex builds, when there's an application server and tests run outside this server (e.g. app server and REST tests) it's a little bit more complicated to set up the per tests coverage, you'll need to set up distributed per-test coverage then.

 

Regarding, your original question regarding failing tests. Yes, if test is failing Clover won't include its contribution to overall coverage stats. The reasoning behind this behavior is that since the test fails, its not trustworthy to say it provide test coverage (confidence) to your code. 

In case you still want to include coverage from failing tests, you can do it by:

* Setting up an reportDescriptor in Maven project

* Configuring reportDescriptor to includeFailedTestCoverage 

 

Cheers,

Grzegorz Lewandowski

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Monday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

486 views 0 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you