Search in sources :

Example 1 with BranchPool

use of org.evosuite.coverage.branch.BranchPool in project evosuite by EvoSuite.

the class StatisticsSender method sendCoveredInfo.

private static void sendCoveredInfo(TestSuiteChromosome testSuite) {
    Set<String> coveredMethods = new HashSet<String>();
    Set<Integer> coveredTrueBranches = new HashSet<Integer>();
    Set<Integer> coveredFalseBranches = new HashSet<Integer>();
    Set<String> coveredBranchlessMethods = new HashSet<String>();
    Set<Integer> coveredLines = new HashSet<Integer>();
    Set<Integer> coveredRealBranches = new HashSet<Integer>();
    Set<Integer> coveredInstrumentedBranches = new HashSet<Integer>();
    for (TestChromosome test : testSuite.getTestChromosomes()) {
        ExecutionTrace trace = test.getLastExecutionResult().getTrace();
        coveredMethods.addAll(trace.getCoveredMethods());
        coveredTrueBranches.addAll(trace.getCoveredTrueBranches());
        coveredFalseBranches.addAll(trace.getCoveredFalseBranches());
        coveredBranchlessMethods.addAll(trace.getCoveredBranchlessMethods());
        coveredLines.addAll(trace.getCoveredLines());
    }
    int coveredBranchesInstrumented = 0;
    int coveredBranchesReal = 0;
    if (Properties.ERROR_BRANCHES || Properties.EXCEPTION_BRANCHES) {
        BranchPool branchPool = BranchPool.getInstance(TestGenerationContext.getInstance().getClassLoaderForSUT());
        for (Integer branchId : coveredTrueBranches) {
            Branch b = branchPool.getBranch(branchId);
            if (b.isInstrumented())
                coveredBranchesInstrumented++;
            else {
                coveredBranchesReal++;
            }
        }
        for (Integer branchId : coveredFalseBranches) {
            Branch b = branchPool.getBranch(branchId);
            if (b.isInstrumented())
                coveredBranchesInstrumented++;
            else {
                coveredBranchesReal++;
            }
        }
    } else {
        coveredBranchesReal = coveredTrueBranches.size() + coveredFalseBranches.size();
    }
    ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Covered_Goals, testSuite.getCoveredGoals().size());
    ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Covered_Methods, coveredMethods.size());
    ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Covered_Branches, coveredTrueBranches.size() + coveredFalseBranches.size());
    ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Covered_Branchless_Methods, coveredBranchlessMethods.size());
    ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Covered_Branches_Real, coveredBranchesReal);
    ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Covered_Branches_Instrumented, coveredBranchesInstrumented);
    ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Covered_Lines, coveredLines.size());
}
Also used : Branch(org.evosuite.coverage.branch.Branch) ExecutionTrace(org.evosuite.testcase.execution.ExecutionTrace) BranchPool(org.evosuite.coverage.branch.BranchPool) TestChromosome(org.evosuite.testcase.TestChromosome) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Branch (org.evosuite.coverage.branch.Branch)1 BranchPool (org.evosuite.coverage.branch.BranchPool)1 TestChromosome (org.evosuite.testcase.TestChromosome)1 ExecutionTrace (org.evosuite.testcase.execution.ExecutionTrace)1