Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Snapshot printer does not extract the source-file-to-relevant tests mapping

kvallish March 5, 2020

I was able to generate a report with per-test mapping for my functional tests, but the snapshot printer does not reflect this mapping.

Am referring to https://community.atlassian.com/t5/Clover-questions/Is-there-a-supported-way-to-extract-the-source-file-to-relevant/qaq-p/301804 where I had seen it working. The snapshot printer gave "All files" section and "Hitting tests" which listed each source file being hit by its respective test cases.

 

I do not see it happening anymore. Am using a merged database to snapshot. The sections exist but under "All files" I see test java file names instead of product java file names. In fact, in the entire snapshot printer output, I do not see a single source code file names at all. All file names are just test names. Am using clover-4.4.1.jar for all my operations.

 

Has anything changed or am I missing something obvious @Marek Parfianowicz ?

2 answers

1 accepted

0 votes
Answer accepted
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 9, 2020

Hello,

1. As a first step please check if Clover correctly recognised your application and test classes. In the HTML report you shall see all business logic on the 'Application code' tab and all test classes on the 'Test code' tab.

2. Next, please check if you correctly collected per-test code coverage data. In the HTML report, pick few classes and check if you have correct tests listed in the 'Tests hitting this class' dialog.

3. Also please check if you don't have too many tests failing. The reason is that by default Clover discards per-test code coverage from failed tests. You can change this setting, however. See 'includeFailedTestCoverage' option for <clover-report> (an Ant task) or clover:clover (Maven goal).

Once everything is OK, please try check how the clover:snapshot works.

4. Try to create coverage snapshots from individual modules, i.e. skip the database merge step. Do you see correct content there? If not, maybe coverage recording files are missing? They're usually named clover.db<some_hash> and clover.db<some_long_hash>.s

5. Finally, please test the merge task. Ensure you've provided all clover.db database files and coverage recording files.

Cheers
Marek

kvallish March 10, 2020

Step 4 was the clue.

Seems that the issue is due to the below TAG in my pom.xml

<cloverDatabase>${project.basedir}/clover_tests.db</cloverDatabase> 

Since I was giving a different path for test clover database, the clover:snapshot goal was not taking the command line override (neither -Dmaven.clover.cloverMergeDatabase nor -Dmaven.clover.cloverDatabase helped) to specify the merged database to be snapshotted.

 

To workaround the problem, I have created a local variable in pom and using that to override. During clover:merge and clover:clover, I do not pass the override and hence the report is generated correctly. During clover:snapshot, I pass the override and point it to the merged database.

 

Accepting this as answer since it led me to it.

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 9, 2020

The most frequent issues are:

  • incorrect test patterns, so that tests files are not recognised as test code
  • missing code coverage data (e.g. tests were executed first on non-instrumented code)
  • discarded coverage because of failing tests
  • build setup mistakes, resulting in missing files (e.g. tests were executed on the remote machine, but coverage recording files not copied back for the report generation step)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events