Class 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.
    • 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.
      • classesUnderTest

        protected final Set<@BinaryName String> classesUnderTest
        Names of all the classes under test.
    • 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 into executionData.
      • 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 the branchCoverageMap 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
      • getBranchCoverageForMethod

        public Double getBranchCoverageForMethod​(String methodName)
        Returns the uncovered branch ratio associated with the input method.
        Parameters:
        methodName - name of the method to examine
        Returns:
        uncovered branch ratio associated with the method