Please find the below steps which I followed to capture code coverage for Functional Tests(Selenium Automation Scripts) using Clover.
Step 1 : I downloaded a sample petclinic application which is a java spring-boot application.
Step 2 : Then managed to instrument the code using maven goal - mvn clover:instrument
Step 3 : Clover DB and a Instrumented jar will be generated as Clover artifacts after instrumentation.
Step 4 : Start the server using the Instrumented Jar pointing towards Clover DB as mentioned bellow.
java –jar -Dclover.initstring.basedir={CloverDatabaseLocation} {InstrumentedBootableJar}
Step 5 : Run TestNG Functional Tests(Selenium Automation Scripts) from a different instance against the application URL. These tests are not included in the application source code.
Step 6 : Generate a report using mvn clover:clover goal.
Findings : The code coverage will be recorded and displayed on the report.
But under "Test Results", the following message was populated. So it is not possible to get the PerTestCoverage.
--------------------------------------------------------------------------------------------------
No test results
No test results could be found. Please ensure that you have instrumented your unit tests correctly.
--------------------------------------------------------------------------------------------------
Is there a way we can tell openclover that this particular test started and ended at this time or some similar mechanism to capture Tests and Per Test Coverage for functional tests?
Note: Functional tests are in a different project which will run on a different instance.
Thanks in Advance.
Hey,
In order to have Clover/OpenClover recognize per-test coverage you must instrument test sources as well.
Furthermore in a setup like your, when tests run in different JVM than an app you must use distributed coverage feature, which basically mean instrumenting sources with proper option and then starting both JVMs (an app and test) with specific system properties
Here's documentation how to achieve that: https://confluence.atlassian.com/clover/using-distributed-per-test-coverage-184025273.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.