It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

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? 

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

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
Community showcase
Posted in Jira

How InVision centralized their tools and scaled their remote team with Atlassian and Slack

Hi Atlassian Community, We recently published a case study that we thought you might be interested in. Learn about how InVision built their fully remote company’s culture using Atlassian and Slack ...

210 views 0 1
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you