application code coverage after running UI selenium functional tests

1k Views Asked by At

I am trying to get java source code coverage after testing with a GUI based functional test using selenium. what all source (actual application) code( NOT selenium test code) was executed or covered after running the selenium functional tests in java.

Is this can be achieved using Emma or jacoco or any other? Anyone who has done this could please give me an idea to start this ?

2

There are 2 best solutions below

0
Ira Baxter On

Our Java Test Coverage tool can do this.

The process is straightfoward:

  1. Apply the Test Coverage tool instrumenter to your source code and compile.
  2. Run the application, exercising it any way you desire (including running selenium, or hand interaction, or unit tests)
  3. Cause the application to exit from main.
  4. The instrumenter's code inserted in main will write coverage data
  5. Display/explore the test coverage with the tools GUI interface

You may have a long-running (server) application that doesn't naturally exit; in that case you can't get the test coverage dumped by exiting main because you didn't exit. In this case, you add a call to the tool's DumpTestCoverage() method, at some place in your application that you can cause to be executed by some interaction with the application. Then when you want a snapshot, simply exercise that feature.

0
Cowarrior On

I always use Jacoco plugin with Gradle. It cool in a way that it generates report and makes everything simple. You can configure it in build.gradle file.