Search in sources :

Example 1 with ExecutableChromosome

use of org.evosuite.testcase.ExecutableChromosome in project evosuite by EvoSuite.

the class TestSuiteFitnessFunction method runTestSuite.

/**
 * <p>
 * runTestSuite
 * </p>
 *
 * @param suite
 *            a {@link org.evosuite.testsuite.AbstractTestSuiteChromosome}
 *            object.
 * @return a {@link java.util.List} object.
 */
protected List<ExecutionResult> runTestSuite(AbstractTestSuiteChromosome<? extends ExecutableChromosome> suite) {
    List<ExecutionResult> results = new ArrayList<ExecutionResult>();
    for (ExecutableChromosome chromosome : suite.getTestChromosomes()) {
        // Only execute test if it hasn't been changed
        if (chromosome.isChanged() || chromosome.getLastExecutionResult() == null) {
            ExecutionResult result = chromosome.executeForFitnessFunction(this);
            if (result != null) {
                results.add(result);
                // .clone();
                chromosome.setLastExecutionResult(result);
                chromosome.setChanged(false);
            }
        } else {
            results.add(chromosome.getLastExecutionResult());
        }
    }
    suite.setChanged(false);
    return results;
}
Also used : ExecutableChromosome(org.evosuite.testcase.ExecutableChromosome) ArrayList(java.util.ArrayList) ExecutionResult(org.evosuite.testcase.execution.ExecutionResult)

Example 2 with ExecutableChromosome

use of org.evosuite.testcase.ExecutableChromosome in project evosuite by EvoSuite.

the class ReadabilitySuiteFitness method getFitness.

/**
 */
@Override
public double getFitness(AbstractTestSuiteChromosome<? extends ExecutableChromosome> suite) {
    double average = 0.0;
    for (ExecutableChromosome ec : suite.getTestChromosomes()) {
        average += getScore(ec.toString());
    }
    average /= suite.getTestChromosomes().size();
    updateIndividual(this, suite, average);
    return average;
}
Also used : ExecutableChromosome(org.evosuite.testcase.ExecutableChromosome)

Aggregations

ExecutableChromosome (org.evosuite.testcase.ExecutableChromosome)2 ArrayList (java.util.ArrayList)1 ExecutionResult (org.evosuite.testcase.execution.ExecutionResult)1