Package randoop.generation
Class CoverageTracker
- java.lang.Object
-
- randoop.generation.CoverageTracker
-
public class CoverageTracker extends Object
Tracks the branch coverage of each method under test. Specifically, for each method under test, this class records the total number of branches and the number of branches that have not been covered in generated tests. This class periodically updates branch coverage information for each method from Jacoco's data structures.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CoverageTracker.DummySessionInfoVisitor
AnISessionInfoVisitor
that does nothing.
-
Field Summary
Fields Modifier and Type Field Description private Map<String,Double>
branchCoverageMap
Map from method name to uncovered branch ratio (in Jacoco terms, the "missed ratio").protected Set<@BinaryName String>
classesUnderTest
Names of all the classes under test.private org.jacoco.core.data.ExecutionDataStore
executionData
A local copy of Jacoco's in-memory store of the coverage information for all classes under test.
-
Constructor Summary
Constructors Constructor Description CoverageTracker(Set<ClassOrInterfaceType> classInterfaceTypes)
Initialize the coverage tracker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
collectCoverageInformation()
Retrieve execution data from the Jacoco Java agent and merge the coverage information intoexecutionData
.Double
getBranchCoverageForMethod(String methodName)
Returns the uncovered branch ratio associated with the input method.private String
getResourceFromClassName(@BinaryName String className)
Construct the absolute resource name of a class given a class name.void
updateBranchCoverageMap()
Updates branch coverage information for all methods under test.
-
-
-
Field Detail
-
executionData
private final org.jacoco.core.data.ExecutionDataStore executionData
A local copy of Jacoco's in-memory store of the coverage information for all classes under test.
-
branchCoverageMap
private final Map<String,Double> branchCoverageMap
Map from method name to uncovered branch ratio (in Jacoco terms, the "missed ratio"). In cases where a method's total branches is zero, the uncovered branch ratio is NaN, and this map uses zero instead.
-
-
Constructor Detail
-
CoverageTracker
public CoverageTracker(Set<ClassOrInterfaceType> classInterfaceTypes)
Initialize the coverage tracker.- Parameters:
classInterfaceTypes
- all the classes under test
-
-
Method Detail
-
collectCoverageInformation
private void collectCoverageInformation()
Retrieve execution data from the Jacoco Java agent and merge the coverage information intoexecutionData
.
-
updateBranchCoverageMap
public void updateBranchCoverageMap()
Updates branch coverage information for all methods under test. At this point, Jacoco has already generated coverage data while Randoop has been constructing and executing its test sequences. Coverage data is now collected and thebranchCoverageMap
field is updated to contain the updated coverage information of each method branch.
-
getResourceFromClassName
private String getResourceFromClassName(@BinaryName String className)
Construct the absolute resource name of a class given a class name.- Parameters:
className
- binary name of class- Returns:
- absolute resource name of the class
-
-