WARN: No coverage recordings found. No report will be generated.

Se Ts June 10, 2014

Steps that bring to this warning

1. Create simple maven project

2. In pom.xml add maven-clover2-plugin and reporting plugin

3. from command line

After the last step the following warning is displayed - WARN: No coverage recordings found. No report will be generated.

The things are different when instead of running from command line, running from Eclipse by:

  • enabling clover on project
  • run the specific class from configuration as "Run Clover as"
  • run HtmlReportRunner.java

After these three steps report is generated.

My point is to make it work when running from cmd.

Will appraciate anykind of help/suggestion

Thanks,

Sevak

1 answer

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 10, 2014

Did you run your tests (mvn test)?

Se Ts June 11, 2014

this is the next what I would like to ask you, look we have two maven projects - DEV project and separately QA project, which is testing DEV codes (all the tests are located in QA project ), we do it using testNG.

So how can we compute code coverage in this particular case?

Shell we also instrument QA project codes? Or there should be different approach?

Please advise.

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 11, 2014

In order to get a code coverage report you have to call:

1) mvn clean - in order to ensure that old, non-instrumented classes will be removed (unless you have a dedicated build where code is always compiled with Clover enabled)

2) mvn clover2:setup compile or mvn clover2:setup test-compile - in order to enable Clover and to compile application and test classes

3) mvn test or mvn integration-test or mvn verify - in order to run your tests and record code coverage

4) mvn clover2:aggregate or mvn clover2:merge - in order to merge Clover databases (unless you use singleCloverDatabase=true option)

4) mvn clover2:clover - to generate Clover reports

All these goals can be run in a single mvn command. So typically it is:

mvn clean clover2:setup verify clover2:aggregate clover2:clover

You wrote that you call the "mvn clean install" (followed by mvn with Clover goals). May I ask you why do you call the "install" goal? It it because you need to install some artifacts for further testing?

You wrote that you have tests in a separate QA project. How does the QA project load code from a DEV project? I suppose that you have a following setup:

* first you run "mvn install" in DEV project to install DEV artifacts (JARs) into local ~/.m2 cache

* QA project has dependencies to DEV artifacts (JARs) in it's pom.xml, so

* next you run "mvn test" on QA and it fetches JARs from ~/.m2 and runs tests on them.

Is my guess correct?

Do you build DEV and QA projects on the same machine? Is it a dedicated machine for QA testing? Why am I asking? Well, because we may need to figure out how to pass DEV artifacts to QA, ensuring that:

* your QA will fetch instrumented DEV jars and not the normal ones and

* you will not accidentally install/deploy instrumented DEV jars in a location (directory/server/repostory...) where you expect to have non-instrumented jars only

Se Ts June 11, 2014

before describing in more details my situation, I would like to make clear for me something. So my general understanding is that, if I have instrumented jar of project "A", then I can calculate coverage even by simply running some method of other project named "B", which just calls one of the methods of instrumented "A" project, (I mean there is no need to have junit tests or tests written using testng in project "B", in order to calculate coverage of "A")

Now let me describe in more details what I have done.

1. Created Dev maven project

2. run

  • mvn clean install
  • mvn clover2:clean clover2:instrument clover2:aggregate

3. As a result of step "2", I have instrumented jar in target folder also in local repo, also coverage.db file is created under .clover folder

4. Created QA maven project and include Dev project as a maven dependancy

5. Wrote method TestClass#test() in QA project which calls some method of Dev project

6. run method TestClass#test().

As a result of step "6" I expect that coverage.db should be filled somehow(method usage of Dev project will be recorded) and when I run mvn clover2:clover I would get the final report.

But instead of that, I am getting the follwoing exception

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.sevak.DevCode$__CLR3_3_000hwc3qt0q
at com.sevak.DevCode.someFunc(DevCode.java:7)
at com.sevak.TestClass.test(TestClass.java:7)

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 12, 2014
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 12, 2014

if I have instrumented jar of project "A", then I can calculate coverage even by simply running some method of other project named "B"

Indeed. As soon as code in project A is instrumented, it will record code coverage, no matter whether the project B has been instrumented or not.

3. As a result of step "2", I have instrumented jar in target folder also in local repo, also coverage.db file is created under .clover folder

4. Created QA maven project and include Dev project as a maven dependancy

Because of the fact that you're using clover2:instrument goal, Clover forks a parallel build life cycle and all artifacts produced have the -clover.jar suffix. Can you confirm that you QA project has a dependency to DEV project with a <classifier>clover</classifier>?

But instead of that, I am getting the follwoing exception:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.sevak.DevCode$__CLR3_3_000hwc3qt0q

The "NoClassDefFoundError ...SomeClass$__CLR..." means that JVM was unable to load a class instrumented by Clover. It means that you don't have a clover.jar on your class path in the QA project.

Please add a following dependency to your QA project:

&lt;dependency&gt;
  &lt;groupId&gt;com.cenqua.clover&lt;/groupId&gt;
  &lt;artifactId&gt;clover&lt;/artifactId&gt;
  &lt;version&gt;3.3.0&lt;/version&gt;
&lt;/dependency&gt;


Se Ts June 12, 2014

Thank you very much Marek for your support, you help me much really.

The exception is fixed now.

As I describe in my last comment step #6 - run method TestClass#test() from QA project

Here I expect that the method call should be recorded in .clover/coverage.db,

but in fact it does not, since in step #7- when I run HtmlReportRunner.java, report is being generated, but there is no record as a result of TestClass#test(){DevCode.someFunc(); } call. The report only contains unit tests coverage, which I have in Dev project.

What should I do here to make coverage.db contain also method calls from QE project?

I guess that instrumented codes get path of coverage.db from instrumentation.ser file located in jar.

below is the clover related config part of Dev project pom.xml. Am I missing any configuration?

&lt;build&gt;
		&lt;plugins&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;com.atlassian.maven.plugins&lt;/groupId&gt;
				&lt;artifactId&gt;maven-clover2-plugin&lt;/artifactId&gt;
				&lt;version&gt;3.3.0&lt;/version&gt;
				&lt;configuration&gt;
					&lt;licenseLocation&gt;C:\clover.license&lt;/licenseLocation&gt;
					&lt;cloverDatabase&gt;C:\Users\sts\Workspaces\MyEclipse Professional 2014\myClover2\.clover\coverage.db&lt;/cloverDatabase&gt;
					&lt;cloverMergeDatabase&gt;C:\Users\sts\Workspaces\MyEclipse Professional 2014\myClover2\.clover\coverage.db&lt;/cloverMergeDatabase&gt;
					&lt;includesTestSourceRoots&gt;true&lt;/includesTestSourceRoots&gt;
					&lt;singleCloverDatabase&gt;true&lt;/singleCloverDatabase&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;
		&lt;/plugins&gt;
	&lt;/build&gt;
	&lt;reporting&gt;
		&lt;plugins&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;com.atlassian.maven.plugins&lt;/groupId&gt;
				&lt;artifactId&gt;maven-clover2-plugin&lt;/artifactId&gt;
			&lt;/plugin&gt;
		&lt;/plugins&gt;
	&lt;/reporting&gt;


Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events