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.
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
It should rather be
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?
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.
Plan and track how teams spend their time and effort may represent a rocket science for many team leaders. Not rarely they need to deal with a considerable amount of variables to “hit the tar...
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