|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface CoverageCalculator
Specification for how to calculate test coverage rates. Typical usage would be along the lines in the example shown below:
// Acquire a CoverageCalculator
CoverageCalculator calc = new SomeCoverageCalculator();
// Start running the tests, and add execution steps for
// all SourceLocations the tests.
//
// This is done in quite another form in reality, but
// corresponding pseudo-code is shown below.
UnitTestRunner runner = new SomeParticularTestRunner(config);
List<InstrumentedTest> allTestsInProject = getAllInstrumentedTestsInProject();
for(InstrumentedTest currentTest : allTestsInProject) {
// Add the listener
currentTest.addSourceLocationListener(calc.getSourceLocationListener());
// Now run the test
runner.execute(currentTest);
}
// Create some filters to define which measurements we are interested in.
final SourceLocationFilter somePackageFilter = new SourceLocationFilter("some\\.package\\.name");
final SourceLocationFilter someClassFilter = new SourceLocationFilter("some\\.package\\.name, "SomeClass");
// Calculate some coverage rates.
double allPackageLineCoverage = calc.getCoverage(somePackageFilter, CoverageType.LINE);
double allPackageBranchCoverage = calc.getCoverage(somePackageFilter, CoverageType.BRANCH);
double allClassLineCoverage = calc.getCoverage(someClassFilter, CoverageType.LINE);
double allClassBranchCoverage = calc.getCoverage(someClassFilter, CoverageType.BRANCH);
| Method Summary | |
|---|---|
double |
getCoverage(SourceLocationFilter filter,
CoverageType type)
Convenience method, retrieving Coverage rate as a supplied type |
Rate |
getCoverageRate(SourceLocationFilter filter,
CoverageType type)
Retrieves the coverage rate for the supplied CoverageType. |
SourceLocationListener |
getSourceLocationListener()
Retrieves a SourceLocationListener used to record execution steps ("hits"/"touches") of all SourceLocations within tests into this CoverageCalculator. |
| Method Detail |
|---|
Rate getCoverageRate(SourceLocationFilter filter,
CoverageType type)
filter - The SourceLocationFilter defining which CoverageRecords should be
included in the retrieved Rate.type - The CoverageType for which coverage is desired.
double getCoverage(SourceLocationFilter filter,
CoverageType type)
filter - The SourceLocationFilter defining which CoverageRecords should be
included in the retrieved Rate.type - The CoverageType for which coverage is desired.
SourceLocationListener getSourceLocationListener()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||