I have an automation framework based out of Selenium Web driver. I want to find out the extent to which automated test scenarios covers various sections of code. Can some one please suggest a code coverage tool for web application.(Preferably a tool which gives a report captures the sections of code which is not tested or less tested)
I think you should be able to use JaCoCo to gather coverage of the backend, but there are more coverage tools for Java see: http://en.wikipedia.org/wiki/Java_Code_Coverage_Tools
Process looks something like this:
- Start application with coverage tool enabled
- Run tests against web-app instance
- Generate report of coverage files
See this article about integrating Jenkins, Sonar and JaCoco to get and report on code coverage of a Java web-app: http://deors.wordpress.com/2012/02/02/selenium-webdriver-grid-3/
Selenium WebDriver does not test code in the same way as a kit like JUnit. Code coverage tools are not an exact science even for unit tests. With Selenium WebDriver you are testing the views of an application. You could potentially look at the code in your views that are covered in you WebDriver tests and estimate how much code is covered. However I would consider this to be a useless metric.
I would measure my WebDriver tests in terms of stories or actions. e.g.
- Tests cover adding a user
- Tests cover creating a document
- Tests do not cover editing a document