Experience with code coverage

622 views
Skip to first unread message

Stefan Lecho

unread,
Feb 16, 2013, 8:02:01 AM2/16/13
to robotframe...@googlegroups.com
Hi,

I have successfully written test cases with the robot framework to test my Swing-based application.
Based on these test cases, I would like to generate a code coverage report of the Java code of this client.
I'm using the robot-maven-plugin to run the tests, so it would be nice if I could use Cobertura or Jacoco to generate the code coverage report.

Has anyone experience with this ?

Regards, Stefan Lecho.

Pekka Klärck

unread,
Feb 18, 2013, 3:56:11 PM2/18/13
to stl...@gmail.com, robotframe...@googlegroups.com
2013/2/16 Stefan Lecho <stl...@gmail.com>:
There shouldn't be anything special in using code coverage tools with
Robot than using them without it. Typically code coverage tools
require you to instrument your code first. After that you just run
your tests against the instrumented version.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Hi-Fi

unread,
Feb 19, 2013, 1:06:39 AM2/19/13
to robotframe...@googlegroups.com
I made couple of tries with cobertura and Jacoco. As Peke mentuoned, there's nothing fancy about coverige; just compile with instrumentation, and then process the reports.

That's where the "fun part" came; with cobertura it's easy to generate reports, and those were nice, too, but couldn't be used in Sonar (because only way to get integration test reports to it is to provide jacoco's file). And even-though Jacoco providec it's coverage report, Sonar wasn't able to use it at server. Local version worked fine.

But, if you don't need to include those reports to e.g. Sonar, Cobertura is quite nice and easy way to get separate coverage reports (especially when using Maven build).

Stefan Lecho

unread,
Feb 19, 2013, 3:43:58 AM2/19/13
to robotframe...@googlegroups.com
In my case, the client classes and robot test cases are defined in two separate projects: nova-client and nova-robot. The nova-robot project has a Maven dependency on nova-client. If I want to use Cobertura, I should apply the following scenario:
  1. Generate with Cobertura the instrumented nova-client-instrumented.jar.
  2. Define in nova-robot a dependency on nova-client-instrumented.jar.
  3. Run the robot test cases.
  4. Generate the Cobertura test coverage report in the nova-robot project.

I have no idea how to implement step 2: "Define in nova-robot a dependency on nova-client-instrumented.jar.".

Have you been able to do this ?

Stefan Lecho

unread,
Feb 19, 2013, 4:43:51 AM2/19/13
to robotframe...@googlegroups.com
Based on http://stackoverflow.com/questions/2026685/how-to-change-the-default-output-from-a-maven-2-cobertura-instrument-goal, I've been able to generate the instrumented nova-client.jar and add it as a Maven dependency.

Now, I have a problem with step 4: "Generate the Cobertura test coverage report in the nova-robot project.".
I've tried to configure the maven-failsafe-plugin, but this one is expecting Java classes to run as integration tests. The Robot Test Cases are not recognized and can not be executed by the failsafe plugin.

Any ideas ?

Stefan Lecho

unread,
Feb 28, 2013, 4:00:38 AM2/28/13
to robotframe...@googlegroups.com
Any ideas on how to enable code coverage with the maven-failsafe-plugin ?
Reply all
Reply to author
Forward
0 new messages