Search in sources :

Example 1 with OutputObserver

use of org.evosuite.coverage.io.output.OutputObserver in project evosuite by EvoSuite.

the class CoverageGoalTestNameGenerationStrategy method getUpdatedResults.

/**
 * Some criteria require re-execution with observers. Make sure the results are up-to-date
 *
 * @param requiredCriteria
 * @param origResults
 * @return
 */
private List<ExecutionResult> getUpdatedResults(List<Properties.Criterion> requiredCriteria, List<ExecutionResult> origResults) {
    List<ExecutionObserver> newObservers = new ArrayList<ExecutionObserver>();
    if (requiredCriteria.contains(Properties.Criterion.INPUT)) {
        newObservers.add(new InputObserver());
    }
    if (requiredCriteria.contains(Properties.Criterion.OUTPUT)) {
        newObservers.add(new OutputObserver());
    }
    if (newObservers.isEmpty()) {
        return origResults;
    }
    for (ExecutionObserver observer : newObservers) TestCaseExecutor.getInstance().addObserver(observer);
    List<ExecutionResult> newResults = new ArrayList<ExecutionResult>();
    for (ExecutionResult result : origResults) {
        ExecutionResult newResult = TestCaseExecutor.getInstance().runTest(result.test);
        newResults.add(newResult);
    }
    for (ExecutionObserver observer : newObservers) TestCaseExecutor.getInstance().removeObserver(observer);
    return newResults;
}
Also used : ExecutionObserver(org.evosuite.testcase.execution.ExecutionObserver) OutputObserver(org.evosuite.coverage.io.output.OutputObserver) InputObserver(org.evosuite.coverage.io.input.InputObserver) ExecutionResult(org.evosuite.testcase.execution.ExecutionResult)

Aggregations

InputObserver (org.evosuite.coverage.io.input.InputObserver)1 OutputObserver (org.evosuite.coverage.io.output.OutputObserver)1 ExecutionObserver (org.evosuite.testcase.execution.ExecutionObserver)1 ExecutionResult (org.evosuite.testcase.execution.ExecutionResult)1