Test coverage using Sonar

Asked

Viewed 2,488 times

3

I wonder if anyone there has ever used the Sonar to do coverage analysis of tests, I have the following problem, I have two projects.

Project A: It is implemented my tests using Selenium + Testng
Project B: It’s a project where I want to assess the coverage of the tests.

I wonder if there is any way to configure the Sonar so that when executing the project a, the coverage analysis is done on the Project B code?

2 answers

1

Look, we can’t really measure test coverage when using Selenium because we can’t clearly link source code to test scripts with Selenium as with unit tests (which has bytecode instrumentation to make that connection).

Functional automation/acceptance based coverage refers to requirements/accepted, not to code, which makes this coverage analysis impossible. Recommended reading: http://java.dzone.com/articles/code-coverage-metrics-and

What is closest to this, for example, is to be able to track a scenario/acceptance criterion and analyze the coverage on this. There is a tool that does this and has integration with Sonar called Thucydides

Take a look in this example report. Here there is an example of use.

1

I didn’t get to do that, but according to sonar documentation you can configure a multi-module project and include multiple projects through certain file settings sonar-project.properties.

For example, consider the following folder structure:

Estrutura dos projetos

Configuration file:

# Root project information
sonar.projectKey=org.mycompany.myproject
sonar.projectName=My Project
sonar.projectVersion=1.0

# Some properties that will be inherited by the modules
sonar.sources=src

# List of the module identifiers
sonar.modules=module1,module2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.