Clover webapp separate tests on remote system

H Severino July 14, 2017

1. Build the instrumented war file with 

-DflushPolicy=threaded.

2. Deploy to remote server: war file, clover.db, and clover-idea-4.1.2.jar .

3. Add clover.db location to -Dinitstring and

clover-idea-4.1.2.jar to CLASSPATH

4 Restart web app

5. Run tests from regression-test, separate app run from Jenkins

No output files like 

clover.db1uxjcebl6pw7t_1t9_gl3v77_j51erknb.s

What am I missing?

I have looked at the doc pages:

https://confluence.atlassian.com/clover/using-clover-with-maven-+-surefire-test-+-inner-test-classes-285840787.html

https://confluence.atlassian.com/clover/using-clover-for-web-applications-296096967.html

https://confluence.atlassian.com/clover/working-with-distributed-applications-72253463.html

the code runs, but does not report anything.

1 answer

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 21, 2017

Please check the following:

1. Check if you indeed deployed an instrumented WAR file.

Mistakes do happen :) It is possible that you instrumented the code by Clover, but a WAR packaging task took original class files instead of instrumented ones. Check if you have *.class files named like

<base class name>$__CLR<some_hash>.class

inside the WAR. If they are present - you're good.

 

2. Check if Clover was able to find clover.db at runtime.

A wrong path to clover.db is a very common mistake. Because of the fact that your Jenkins workspace is located on a different machine (and folder) than your web application server, you must ensure that it found the clover.db at runtime. Open your application log / console output and look for Clover error messages. Example:

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

 

3. Check if Clover did not fail because of other reasons.

Security manager (https://confluence.atlassian.com/clover/working-with-restricted-security-environments-79169080.html):

[CLOVER] FATAL ERROR: Clover could not be initialised because it has insufficient security privileges. 
Please consult the Clover documentation on the security policy file changes required.

The clover.jar not found on the classpath or in incorrect version:

[CLOVER] FATAL ERROR: Clover could not be initialised. Are you " +
"sure you have Clover in the runtime classpath?

[CLOVER] WARNING: The Clover version used in instrumentation does " +
"not match the runtime version. You need to run instrumented classes against the same version of Clover " +
"that you instrumented with.

 

4. Check if you copied all clover.db databases to your target machine or ensure that only one clover.db is created.

This applies mainly to Maven builds. By default Clover produces clover.db file for every Maven module. In such case I'd advise to use singleCloverDatabase parameter or use an absolute path in cloverDatabase parameter (it will cause that all modules will write to the same db). This way you will have to copy just one file to your web server.

 

5. Ensure that Clover's Distirbuted Coverage feature is enabled.

This applies when you want to collect per-test coverage data (I asssume that yes) and that unit tests are launched on your Jenkins server and they call business logic on your running web application server. 

See https://confluence.atlassian.com/clover/using-distributed-per-test-coverage-184025273.html article how to do this.

 

I hope this helps. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events