When drilling down from the project dashboard, the resource viewer is the ultimate place to view detailed information on a given resource: file or unit tests file. The power of the tool comes from the fact that the resources can be viewed according to different axes of quality.
Viewing Source Code
When drilling down into measures, you will eventually reach the file level and will be able to browse the source code.
This tab displays source code with highlighted syntax.
To display the recently new/modified source code or view the last committers, you need to install the SCM Activity Plugin.
The Coverage tab shows displays the source code annotated decorated with extra information and colors showing the about code coverage (by unit tests and/or integration tests).
In the source code:
- The first column
- displays the number of
- unit tests covering the line (available since Sonar 3.5, was the number of hits by unit tests in versions prior to 3.5)
- The second one displays the number of covered conditions by unit tests out of the total number of conditions to cover
The features described below are available since Sonar 3.
When code coverage by integration tests is collected with help of JaCoCoJava Code Coverage Plugins, all IT coverage measures are displayed in this tab:
A drop down list enables to filter the information to show on the viewer:
When clicking on a figure displayed in the first column, the unit tests covering this specific line are listed:
When selecting Per test > Covered lines in the second dropdown list, a third dropdown list appears. In this latter list, it is possible to select a specific unit test. Then, only lines covered by this unit test are displayed in the source code viewer:
The LCOM4 tab shows blocks of resources within a class that have tight relationship. Having more that one block here probably means that the class is assuming more than one responsibility.
When drilling down into unit tests execution measures, you will eventually reach the unit test class level:
This The Source tab simply displays the source code of your the unit test classfile:
This The Tests tab displays the result of the unit tests belonging to the unit tests test class.
In case the test failed or was in of a failure or an error, the reason is displayed:
Since Sonar 3.5, it is also possible to the mapping of the issue can be viewed.
This unit tests and covered code. The objective is to answer the following questions:
- Which files are covered by a given unit test?
- How many lines of code are covered by a given unit test?
- Which lines are covered by a given unit test?
- Which tests do cover a given line of code?
The Violations tab displays the violations on the unit tests: