Search in sources :

Example 61 with DefaultTestCase

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

the class FixedLengthTestChromosomeFactory method getRandomTestCase.

/**
 * Create a random individual
 *
 * @param size
 */
private TestCase getRandomTestCase(int size) {
    TestCase test = new DefaultTestCase();
    int num = 0;
    TestFactory testFactory = TestFactory.getInstance();
    // Then add random stuff
    while (test.size() < size && num < Properties.MAX_ATTEMPTS) {
        testFactory.insertRandomStatement(test, test.size() - 1);
        num++;
    }
    return test;
}
Also used : DefaultTestCase(org.evosuite.testcase.DefaultTestCase) TestCase(org.evosuite.testcase.TestCase) TestFactory(org.evosuite.testcase.TestFactory) DefaultTestCase(org.evosuite.testcase.DefaultTestCase)

Example 62 with DefaultTestCase

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

the class DiversityObserver method getSuiteSimilarity.

/**
 * Naive similarity comparison between suites simply consists of merging all tests to a single test
 * for each suite, and then comparing these tests
 *
 * @param suite1
 * @param suite2
 * @return
 */
public static double getSuiteSimilarity(TestSuiteChromosome suite1, TestSuiteChromosome suite2) {
    TestCase test1 = new DefaultTestCase();
    for (TestCase test : suite1.getTests()) {
        for (Statement s : test) {
            // These are not valid tests as the variables still point to the original test
            // but that doesn't matter as we're not executing the test
            test1.addStatement(s);
        }
    }
    TestCase test2 = new DefaultTestCase();
    for (TestCase test : suite2.getTests()) {
        for (Statement s : test) {
            test2.addStatement(s);
        }
    }
    return getNeedlemanWunschScore(test1, test2);
}
Also used : DefaultTestCase(org.evosuite.testcase.DefaultTestCase) TestCase(org.evosuite.testcase.TestCase) DefaultTestCase(org.evosuite.testcase.DefaultTestCase)

Example 63 with DefaultTestCase

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

the class ConcolicExecutionTest method testCase81.

@Test
public void testCase81() throws SecurityException, NoSuchMethodException {
    DefaultTestCase tc = buildTestCase81();
    List<BranchCondition> branch_conditions = executeTest(tc);
    assertEquals(1, branch_conditions.size());
}
Also used : DefaultTestCase(org.evosuite.testcase.DefaultTestCase) Test(org.junit.Test)

Example 64 with DefaultTestCase

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

the class ConcolicExecutionTest method testCase46.

@Test
public void testCase46() throws SecurityException, NoSuchMethodException {
    DefaultTestCase tc = buildTestCase46();
    List<BranchCondition> branch_conditions = executeTest(tc);
    assertEquals(10, branch_conditions.size());
}
Also used : DefaultTestCase(org.evosuite.testcase.DefaultTestCase) Test(org.junit.Test)

Example 65 with DefaultTestCase

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

the class ConcolicExecutionTest method testCase90.

@Test
public void testCase90() throws SecurityException, NoSuchMethodException {
    DefaultTestCase tc = buildTestCase90();
    List<BranchCondition> branch_conditions = executeTest(tc);
    assertEquals(3, branch_conditions.size());
}
Also used : DefaultTestCase(org.evosuite.testcase.DefaultTestCase) Test(org.junit.Test)

Aggregations

DefaultTestCase (org.evosuite.testcase.DefaultTestCase)347 Test (org.junit.Test)234 Constraint (org.evosuite.symbolic.expr.Constraint)101 TestCase (org.evosuite.testcase.TestCase)78 ArrayList (java.util.ArrayList)63 CoverageGoalTestNameGenerationStrategy (org.evosuite.junit.naming.methods.CoverageGoalTestNameGenerationStrategy)47 MethodCoverageTestFitness (org.evosuite.coverage.method.MethodCoverageTestFitness)45 IntPrimitiveStatement (org.evosuite.testcase.statements.numeric.IntPrimitiveStatement)41 VariableReference (org.evosuite.testcase.variable.VariableReference)37 TestCaseStringAppendString (com.examples.with.different.packagename.solver.TestCaseStringAppendString)27 TestCaseStringIndexOfString (com.examples.with.different.packagename.solver.TestCaseStringIndexOfString)27 TestCaseStringLastIndexOfString (com.examples.with.different.packagename.solver.TestCaseStringLastIndexOfString)27 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)27 OutputCoverageGoal (org.evosuite.coverage.io.output.OutputCoverageGoal)25 OutputCoverageTestFitness (org.evosuite.coverage.io.output.OutputCoverageTestFitness)25 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)18 GenericMethod (org.evosuite.utils.generic.GenericMethod)17 TestChromosome (org.evosuite.testcase.TestChromosome)16 Method (java.lang.reflect.Method)14 BranchCoverageSuiteFitness (org.evosuite.coverage.branch.BranchCoverageSuiteFitness)14