Web Development Design UK USA India, Web Software Applications Development Programming Web Development Design UK USA India, Web Software Applications Development Programming Contact website development and web design company, advanced portal development UK USA Site Map: Internet applications to discover your NET potential
 
   

Using Cobertura for calculating code coverage of integration tests
 
 
August 8 , 2013
Categories : Java software development | Software development company | Software development tools | Cobertura | Java development company | Code coverage
Share : Facebook Tweet Linkedin
 

We use software development tools, setup and processes at Pegasus InfoCorp based on each client's individual needs. These vary greatly based on the client's current in-house IT processes and standards. In general, tools that are setup and used by our teams are the same as the one's our client's use at their offices. This helps our client's IT teams be comfortable with the tools and processes that are used by their teams at our software development centers.

In this blog, we discuss the usage of Cobertura for calculating code coverage of integration tests. This is based on our experiences while working with a client for Java software development for building an ERP system for their business.

Typically, we use an internally developed integration test system, based on Selenium, to try web application user interfaces. The Selenium tests run from the test environment (such as JBoss) and the tests are run periodically by the continuous integration tool, Jenkins. We automatically export test results with test steps to our wiki and link the test cases with their specific use cases, with a green / red signal indicating clear tests or errors.

We’ve been looking into using Cobertura for the integration tests (besides just the unit tests), and have implemented it using the following steps:

  • Start with building the application, resulting in a .war / .ear file.
  • Let Cobertura instrument this using the cobertura-instrument command line utility (Cobertura can instrument a .jar or .war).
  • Move the cobertura.ser file generated by cobertura-instrument to the directory where your application server runs from. For e.g., if you are using JBoss 4, this is the bin-directory.
  • Start the (application) server.
  • Run the Selenium tests against the environmental with this instrumented application.
  • Stop the application server (if you are using JBoss, ensure jboss.shutdown.forceHaltis is set to false, otherwise, the cobertura.ser file will not be written completely).
  • Generate the XML / HTML report using cobertura-report

It would not be possible to utilize the report in Jenkins (since the Cobertura plugin from Jenkins requires mojo to run before a coverage report is generated). However, it is easily possible to utilize the coverage report in Sonar. It is a little challenging to add the integration tests coverage data to the same project that contains the unit tests coverage data. Nevertheless, one can develop a a different project in Sonar containing the integration tests coverage using Sonar Runner. The sonar-project.properties file would need to be set as follows.

sonar.projectKey=your:key
sonar.projectName=Java Integration Tests
sonar.projectVersion=1.2

tests=src/test/java
sources=../project/src/main/java
sonar.dynamicAnalysis=reuseReports
sonar.cobertura.reportPath=../coverage-report/coverage.xml
sonar.skipDesign=true

There are other tools also (besides Cobertura) which can be used for calculating code coverage – such as JaCoCo. However, Cobertura is the most widely used currently and would work well for any good software development company for Java software development.

 
About The Author

Mitul Dave

View My Profile



To know more about us, our services and solutions, drop us a message or mail us at info@pegasusinfocorp.com
 
The Author
 
Mitul Dave
 
 
Quick Links
 
Home Home
Services Services
Solutions Solutions
Contact Us Contact Us
Sitemap Sitemap
 
 
 
© 2024, Pegasus InfoCorp Pvt. Ltd. All Rights Reserved.