Not able to get code coverage of integration test

Hi We are evaluating to use clover for one of our product. We have a lot of legacy seleniumIDE tests and we want to leverage on clover to perform test optimization. When I run the integration tests clover shows "No classes were hit by this test." I am not sure what am i missing here. Can you pls help. Here is the corgo plugin section from my pom file.

Here is link to my POM XML :- https://onedrive.live.com/redir?resid=C04D20DC7384222A%212014 

Here is the log file :- https://onedrive.live.com/redir?resid=C04D20DC7384222A%212057

Though I have specified <clover.distributed.coverage>host=localhost;port=7777;numclients=1</clover.distributed.coverage> I see in log 

Distributed coverage is enabled with: name=clover.tcp.server;host=localhost;port=1198;timeout=5000;numClients=0;retryPeriod=1000
Starting distributed coverage service.

I know its some configuration issue. But I am not sure what is missing here.

I am running the tests as below :-

mvn -Dclover.server=true  clover2:clean clover2:setup clover2:optimize install  clover2:log  clover2:aggregate clover2:clover clover2:snapshot

&lt;plugin&gt;
				&lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;
				&lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;
				&lt;version&gt;1.2.0&lt;/version&gt;
				&lt;configuration&gt;

					&lt;!-- Container configuration --&gt;
					&lt;container&gt;
						&lt;containerId&gt;tomcat6x&lt;/containerId&gt;
						&lt;type&gt;remote&lt;/type&gt;
						&lt;dependencies&gt;
							&lt;!-- We need clover.jar to be present in container classpath --&gt;
							&lt;dependency&gt;
								&lt;groupId&gt;com.cenqua.clover&lt;/groupId&gt;
								&lt;artifactId&gt;clover&lt;/artifactId&gt;
							&lt;/dependency&gt;
						&lt;/dependencies&gt;
					&lt;/container&gt;
					&lt;systemProperties&gt;
						&lt;clover.distributed.coverage&gt;ON&lt;/clover.distributed.coverage&gt;
		&lt;clover.distributed.coverage&gt;host=localhost;port=7777;numclients=1&lt;/clover.distributed.coverage&gt;
					&lt;/systemProperties&gt;
					&lt;!-- Configuration to use with the Container --&gt;
					&lt;configuration&gt;
						&lt;type&gt;runtime&lt;/type&gt;
						&lt;properties&gt;				&lt;cargo.tomcat.manager.url&gt;http://localhost:8080/manager&lt;/cargo.tomcat.manager.url&gt;
							&lt;cargo.remote.username&gt;deployer&lt;/cargo.remote.username&gt;
							&lt;cargo.remote.password&gt;deployer&lt;/cargo.remote.password&gt;
						&lt;/properties&gt;
					&lt;/configuration&gt;
					&lt;!-- Deployer configuration --&gt;
					&lt;deployer&gt;
						&lt;type&gt;remote&lt;/type&gt;
						&lt;deployables&gt;
							&lt;deployable&gt;
								&lt;groupId&gt;${project.groupId}&lt;/groupId&gt;
								&lt;artifactId&gt;${project.artifactId}&lt;/artifactId&gt;
								&lt;type&gt;war&lt;/type&gt;
							&lt;/deployable&gt;
						&lt;/deployables&gt;
					&lt;/deployer&gt;
				&lt;/configuration&gt;
				&lt;executions&gt;
					&lt;execution&gt;
						&lt;id&gt;deploy&lt;/id&gt;
						&lt;phase&gt;pre-integration-test&lt;/phase&gt;
						&lt;goals&gt;
							&lt;goal&gt;redeploy&lt;/goal&gt;
						&lt;/goals&gt;
						&lt;configuration&gt;
							&lt;type&gt;runtime&lt;/type&gt;
							&lt;properties&gt;
			&lt;cargo.tomcat.manager.url&gt;http://localhost:8080/manager&lt;/cargo.tomcat.manager.url&gt;
								&lt;cargo.remote.username&gt;deployer&lt;/cargo.remote.username&gt;
								&lt;cargo.remote.password&gt;deployer&lt;/cargo.remote.password&gt;
							&lt;/properties&gt;
						&lt;/configuration&gt;
					&lt;/execution&gt;
				&lt;/executions&gt;
			&lt;/plugin&gt;

2 answers

This widget could not be displayed.

Hi Shankar,

 

1) In the pom.xml, in maven-clover2-plugin configuration section you have an empty tag:

<distributedCoverage />

Please do one of the following:

  • remove this tag or
  • use "<distributedCoverage>ON</distributedCoverage>" or
  • use properties in this tag, for instance "<distributedCoverage>host=localhost;numClients=1</distributedCoverage>"

 

2) In the pom.xml, in maven-surefire-plugin configuration section you have:

&lt;property&gt;
  &lt;name&gt;clover.distributed.coverage&lt;/name&gt;
  &lt;value&gt;ON&lt;/value&gt;
&lt;/property&gt;

 

This setting is required only if the <distributedCoverage> has not been set during compilation (in the maven-clover2-plugin). Thus, depending on an action you'll choose in point 1), you may need to remove it.

 

3) In the pom.xml, in cargo-maven2-plugin you have:

&lt;systemProperties&gt;
  &lt;clover.distributed.coverage&gt;ON&lt;/clover.distributed.coverage&gt;
  &lt;clover.distributed.coverage&gt;host=localhost;port=7777;numclients=1&lt;/clover.distributed.coverage&gt;
&lt;/systemProperties&gt;

 

It's not possible to pass the same property twice. The latter one is ignored. Thus, please use only one of them.

 

4) You wrote that you've used a command as follows:

mvn -Dclover.server=true  clover2:clean clover2:setup clover2:optimize 
install  clover2:log  clover2:aggregate clover2:clover clover2:snapshot

In my opinion -Dclover.server=true is obsolete here, because it's already present in maven-surefire-plugin's configuration.

You may also reconsider whether it's necessary to run "install" phase - please note that this causes that JARs containing instrumented code will be installed to ~/.m2. The most probably running "test" or "verify" should be sufficient.

 

Cheers
Marek

This widget could not be displayed.

Hi Shankar,

 

Coming back to your question:

When I run the integration tests Clover shows "No classes were hit by this test." I am not sure what am i missing here.


There are few possible reasons of this.

1) First of all - do you see any code coverage for your application when you run integration tests? I'm asking about the global coverage, not the per-test coverage. If there's no global coverage then it may be caused by a fact that application instrumented by Clover was unable to locate clover.db file. If this happens, you should see a proper error message in application's log, such as:

"CLOVER: Unable to load the coverage database at <path>"
"CLOVER: No coverage data will be gathered."


I suspect that you may have this problem. Could you check your logs, please?


I've found that in maven-surefire-plugin you're passing location of the Clover database in a wrong way:

&lt;plugin&gt;
  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
  &lt;version&gt;2.17&lt;/version&gt;
  &lt;configuration&gt;
    &lt;cloverDatabase&gt;/Users/i306565/.clover/clover.db&lt;/cloverDatabase&gt;
  &lt;/configuration&gt;
&lt;/plugin&gt;

Surefire does not have the <cloverDatabase> configuration option. Therefore, if you need to pass this path, you have to use a property. However, the most probably you don't need this property here at all (sic!). It's because tests are being launched from the same working directory as the build  is performed. Thus, there shall be no problem with locating the database.


However, as you're using Cargo plugin to run your application, you may need to pass this property here:

&lt;plugin&gt;
  &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;
  &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;
  &lt;version&gt;1.2.0&lt;/version&gt;
  &lt;configuration&gt;
    &lt;clover.initstring&gt;/Users/i306565/.clover/clover.db&lt;/clover.initstring&gt;
    ...
  &lt;/configuration&gt;
&lt;/plugin&gt;



2) If you already see global coverage for both application and integration tests, it may happen that you will see no per-test coverage in an HTML report. Could you please open such report and check if any of your integration tests have some application classes covered?

 

If not, then the most probably distributed coverage did not start properly - please note test execution must not start before "Clover clients" are connected to the "Clover server".

 

I've found the following messages in your build log:

Running com.ariba.demo.ITSeleniumIDETests
Distributed coverage is enabled with: name=clover.tcp.server;host=localhost;port=1198;timeout=5000;numClients=0;retryPeriod=1000
Starting distributed coverage service.

As you can see, "Clover server" started immediately, without waiting for any clients (numClients=0). I don't know what happened on application side, however - could you share an application log too, please?

The most probably you shall use:

&lt;clover.distributed.coverage&gt;numclients=1&lt;/clover.distributed.coverage&gt;

in maven-cargo-plugin; but I have to see logs first to be certain.



And what about problem with test optimization?

In my opinion, as soon as you have per-test coverage for integration tests recorded correctly, test optimization will start working as expected.


Cheers
Marek

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

176 views 2 0
Join discussion

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