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

How do I get functional test to product code coverage mapping?

kvallish March 5, 2018

Hi,

Am trying to get per-test coverage so that I can find what classes of my functional tests cover what classes of product code. My setup and requirement is very similar to https://community.atlassian.com/t5/Clover-questions/Clover-Per-Test-Coverage-for-Automated-Functional-Test/qaq-p/223938.

I have instrumented my product code that has produced a single WAR file and a clover.db. I have deployed the WAR file on my Application server and is ready to test. Since the application is a war file, I modified the tomcat service file (that starts the application) to have the below parameters in JVM options:

JAVA_OPTS = "$JAVA_OPTS -Dclover.distributed.coverage=host=<myTestServerIP> -Dclover.initstring=/path/to/db/clover-app.db"

When I restart the tomcat service, the service comes up normally and am able to access the application via browser (the application did not seem to wait to connect to a Clover server).

Also, my functional tests are in a separate project which I always invoke only using maven command (no ANT anywhere). I have instrumented the test classes using the below command which has produced the clover.db and instrumented code for test classes :

mvn clean clover:instrument-test -DskipTests=true

Now, am trying to run a test but am not sure if anything else needs to be done prior to this. The above link says about copying the .db and instrumented classes to test servers but am not sure what exactly to copy where (I just have the application server and my test server where I build and run test project). When I invoke the test, am using the below maven command:

mvn -o -Dtest=SomeTestClass#someTestMethod test -Dclover.distributed.coverage==numClients=1  -Dclover.server=true -Dclover.initstring=/path/to/clover-test.db

 

What I do not see is the recording files of test classes or clover-test.db but I do see the recording files (clover.db* files) of the application server. Hence am unable to proceed with the merge and report generation step. 

Am I missing something? Please help.

2 answers

1 accepted

1 vote
Answer accepted
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 18, 2018

Few potential issues:

1. You started your application server first, followed by the launching of the test. As a result, the Clover running in application server was unable to connect to the Clover running in test JVM. Please try the opposite order. Start your test first (it will pause as it has numClients=1), followed by the application server.

2. You're calling 'mvn clean clover:instrument-test' followed by 'mvn test'. Why these two steps? Are you sure that the 'mvn test' does not call javac and actually recompile the test class, which has been instrumented previously? Try calling

mvn clean clover:setup test -Dclover.distributed.coverage==numClients=1 -Dclover.server=true -Dclover.initstring=/path/to/clover-test.db

in your test project.

3. You've got double '==' in 

-Dclover.distributed.coverage==numClients=1

It should rather be

-Dclover.distributed.coverage=numClients=1
kvallish May 20, 2018

Yes, that worked. The test now waited for the app server to connect before starting off!!

Now, I have 2 clover databases (test and product) along with their respective recording files. When I try to merge them using the below command, I get the following error:

Command: mvn clover:merge -Dmaven.clover.merge.basedir=/Users/<username>/cloverfiles

"cloverfiles" is a directory having two sub directories, each having the clover database for product and automation and their respective recording files

Error: You must specify one or more coverage databases to merge using a nested  <cloverdb> or <cloverdbset> element.

What might I be missing? 

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2018

Check the includes parameter. By default it has "*.db", so it does not search in subdirectories.

http://openclover.org/doc/maven/4.2.0/merge-mojo.html#includes

0 votes
Warner September 24, 2018

Hi Vallish Kumaraswami,

Sorry for commenting in this thread.

I need to instrument the product code, and then use QE test automation functional tests to verify how how much code is covered through our automation tests.

As I am new to clover, and I would request you to please provide steps to instrument the product code, and run QE functional automation test cases.

Thanks,
David 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events