Interface NewCoverage
-
public interface NewCoverage
This class is used to report code coverage on files. Example:sensorContext.newCoverage().onFile(file) .lineHits(1, 2) .lineHits(2, 5) .lineHits(3, 0) . ... .conditions(3, 4, 2) .conditions(12, 2, 2) . ... .save();
Since 6.2 you can save several reports for the same file and reports will be merged using the following "additive" strategy:- Line hits are cumulated
- We keep the max for condition coverage. Examples: 2/4 + 2/4 = 2/4, 2/4 + 3/4 = 3/4
- Since:
- 5.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description NewCoverage
conditions(int line, int conditions, int coveredConditions)
Call this method as many time as needed to report coverage of conditions.NewCoverage
lineHits(int line, int hits)
Call this method as many time as needed to report coverage hits per line.NewCoverage
ofType(CoverageType type)
Deprecated.since 6.2 SonarQube merge all coverage reports and don't keep track of different test categoryNewCoverage
onFile(InputFile inputFile)
The covered file.void
save()
Call this method to save the coverage report for the given file.
-
-
-
Method Detail
-
onFile
NewCoverage onFile(InputFile inputFile)
The covered file.
-
ofType
@Deprecated NewCoverage ofType(CoverageType type)
Deprecated.since 6.2 SonarQube merge all coverage reports and don't keep track of different test category
-
lineHits
NewCoverage lineHits(int line, int hits)
Call this method as many time as needed to report coverage hits per line. This method should only be called for executable lines.- Parameters:
line
- Line number (starts at 1).hits
- Number of time the line was hit.
-
conditions
NewCoverage conditions(int line, int conditions, int coveredConditions)
Call this method as many time as needed to report coverage of conditions.- Parameters:
line
- Line number (starts at 1).conditions
- Number of conditions on this line (should be greater than 1).coveredConditions
- Number of covered conditions.
-
save
void save()
Call this method to save the coverage report for the given file. Data will be merged with existing coverage information.
-
-