Search in sources :

Example 41 with TestChromosome

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

the class RegressionSuiteMinimizer method removeUnusedVariables.

/*
   * "borrowed" from TestCaseMinimizer
   */
private void removeUnusedVariables(RegressionTestSuiteChromosome suite) {
    for (TestChromosome testChromosome : suite.getTestChromosomes()) {
        RegressionTestChromosome test = (RegressionTestChromosome) testChromosome;
        boolean changed = TestCaseMinimizer.removeUnusedVariables(test.getTheTest().getTestCase());
        if (changed) {
            test.updateClassloader();
            executeSuite(suite);
        }
    }
}
Also used : TestChromosome(org.evosuite.testcase.TestChromosome)

Example 42 with TestChromosome

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

the class RegressionSuiteMinimizer method executeTest.

/**
 * Execute regression test case on both versions
 *
 * @param regressionTest regression test chromosome to be executed on both versions
 */
private void executeTest(RegressionTestChromosome regressionTest) {
    TestChromosome testChromosome = regressionTest.getTheTest();
    TestChromosome otherChromosome = regressionTest.getTheSameTestForTheOtherClassLoader();
    ExecutionResult result = regressionAssertionGenerator.runTest(testChromosome.getTestCase());
    ExecutionResult otherResult = regressionAssertionGenerator.runTest(otherChromosome.getTestCase());
    regressionTest.setLastExecutionResult(result);
    regressionTest.setLastRegressionExecutionResult(otherResult);
    testChromosome.setLastExecutionResult(result);
    otherChromosome.setLastExecutionResult(otherResult);
}
Also used : ExecutionResult(org.evosuite.testcase.execution.ExecutionResult) TestChromosome(org.evosuite.testcase.TestChromosome)

Example 43 with TestChromosome

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

the class RegressionTestSuiteChromosomeFactory method getChromosome.

/**
 * Factory to manipulate and generate method sequences
 */
/**
 * {@inheritDoc}
 */
@Override
public TestSuiteChromosome getChromosome() {
    RegressionTestSuiteChromosome chromosome = new RegressionTestSuiteChromosome(testChromosomeFactory);
    chromosome.clearTests();
    int numTests = Randomness.nextInt(Properties.MIN_INITIAL_TESTS, Properties.MAX_INITIAL_TESTS + 1);
    for (int i = 0; i < numTests; i++) {
        TestChromosome test = testChromosomeFactory.getChromosome();
        chromosome.addTest(test);
    }
    // logger.trace("Generated new test suite:"+chromosome);
    return chromosome;
}
Also used : TestChromosome(org.evosuite.testcase.TestChromosome)

Example 44 with TestChromosome

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

the class RegressionTestSuiteChromosome method addTests.

@Override
public void addTests(Collection<TestChromosome> tests) {
    for (TestChromosome test : tests) {
        test.setChanged(true);
        addTest(test);
    }
}
Also used : TestChromosome(org.evosuite.testcase.TestChromosome)

Example 45 with TestChromosome

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

the class RegressionTestSuiteChromosome method getTestSuiteForTheOtherClassLoader.

public AbstractTestSuiteChromosome<TestChromosome> getTestSuiteForTheOtherClassLoader() {
    AbstractTestSuiteChromosome<TestChromosome> suite = new TestSuiteChromosome();
    for (TestChromosome regressionTest : tests) {
        RegressionTestChromosome rtc = (RegressionTestChromosome) regressionTest;
        suite.addTest(rtc.getTheSameTestForTheOtherClassLoader());
    }
    return suite;
}
Also used : AbstractTestSuiteChromosome(org.evosuite.testsuite.AbstractTestSuiteChromosome) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) TestChromosome(org.evosuite.testcase.TestChromosome)

Aggregations

TestChromosome (org.evosuite.testcase.TestChromosome)128 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)47 ExecutionResult (org.evosuite.testcase.execution.ExecutionResult)33 TestFitnessFunction (org.evosuite.testcase.TestFitnessFunction)22 ArrayList (java.util.ArrayList)17 TestCase (org.evosuite.testcase.TestCase)17 DefaultTestCase (org.evosuite.testcase.DefaultTestCase)16 HashSet (java.util.HashSet)15 Properties (org.evosuite.Properties)15 Test (org.junit.Test)15 BranchCoverageSuiteFitness (org.evosuite.coverage.branch.BranchCoverageSuiteFitness)14 HashMap (java.util.HashMap)11 DefaultLocalSearchObjective (org.evosuite.ga.localsearch.DefaultLocalSearchObjective)10 AbstractTestSuiteChromosome (org.evosuite.testsuite.AbstractTestSuiteChromosome)8 LinkedHashMap (java.util.LinkedHashMap)7 Foo (com.examples.with.different.packagename.symbolic.Foo)6 LinkedHashSet (java.util.LinkedHashSet)6 Set (java.util.Set)6 TestSuiteFitnessFunction (org.evosuite.testsuite.TestSuiteFitnessFunction)6 Map (java.util.Map)5