Search in sources :

Example 86 with TestCase

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

the class MutationAssertionSystemTest method test1.

@Ignore
@Test
public void test1() {
    TestSuiteChromosome suite = generateSuite(ExampleObserverClass.class);
    Assert.assertTrue(suite.size() > 0);
    for (TestCase test : suite.getTests()) {
        Assert.assertTrue("Test has no assertions: " + test.toCode(), test.hasAssertions());
    }
}
Also used : TestCase(org.evosuite.testcase.TestCase) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 87 with TestCase

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

the class MutationAssertionSystemTest method test2.

@Ignore
@Test
public void test2() {
    TestSuiteChromosome suite = generateSuite(ExampleFieldClass.class);
    Assert.assertTrue(suite.size() > 0);
    for (TestCase test : suite.getTests()) {
        Assert.assertTrue("Test has no assertions: " + test.toCode(), test.hasAssertions());
    }
}
Also used : TestCase(org.evosuite.testcase.TestCase) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 88 with TestCase

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

the class MutationAssertionSystemTest method test4.

@Ignore
@Test
public void test4() {
    TestSuiteChromosome suite = generateSuite(ExampleStaticVoidSetterClass.class);
    Assert.assertTrue(suite.size() > 0);
    for (TestCase test : suite.getTests()) {
        if (test.size() > 1)
            Assert.assertTrue("Test has no assertions: " + test.toCode(), test.hasAssertions());
    }
}
Also used : TestCase(org.evosuite.testcase.TestCase) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 89 with TestCase

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

the class OverloadSystemTest method testIsOverloadedInstance.

@Test
public void testIsOverloadedInstance() throws NoSuchMethodException, SecurityException {
    Method m1 = Overload.class.getMethod("execute", Overload.class, Overload.class);
    Method m2 = Overload.class.getMethod("execute", Overload.class, Object.class);
    GenericMethod gm1 = new GenericMethod(m1, Overload.class);
    GenericMethod gm2 = new GenericMethod(m2, Overload.class);
    TestCase test = new DefaultTestCase();
    GenericConstructor gc = new GenericConstructor(Overload.class.getConstructors()[0], Overload.class);
    ConstructorStatement cs = new ConstructorStatement(test, gc, new ArrayList<VariableReference>());
    VariableReference overloadInstance = test.addStatement(cs);
    ConstructorStatement ocs = new ConstructorStatement(test, new GenericConstructor(Object.class.getConstructors()[0], Object.class), new ArrayList<VariableReference>());
    VariableReference objectInstance = test.addStatement(ocs);
    List<VariableReference> vars1 = new ArrayList<VariableReference>();
    vars1.add(overloadInstance);
    vars1.add(overloadInstance);
    List<VariableReference> vars2 = new ArrayList<VariableReference>();
    vars2.add(overloadInstance);
    vars2.add(objectInstance);
    Assert.assertFalse(gm1.isOverloaded(vars1));
    Assert.assertTrue(gm2.isOverloaded(vars1));
    Assert.assertTrue(gm1.isOverloaded(vars2));
    Assert.assertFalse(gm2.isOverloaded(vars2));
}
Also used : ConstructorStatement(org.evosuite.testcase.statements.ConstructorStatement) VariableReference(org.evosuite.testcase.variable.VariableReference) DefaultTestCase(org.evosuite.testcase.DefaultTestCase) TestCase(org.evosuite.testcase.TestCase) ArrayList(java.util.ArrayList) GenericConstructor(org.evosuite.utils.generic.GenericConstructor) GenericMethod(org.evosuite.utils.generic.GenericMethod) Method(java.lang.reflect.Method) GenericMethod(org.evosuite.utils.generic.GenericMethod) DefaultTestCase(org.evosuite.testcase.DefaultTestCase) Test(org.junit.Test)

Example 90 with TestCase

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

the class CloneMeSystemTest method testCloneMe.

@Test
public void testCloneMe() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = CloneMe.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    List<TestCase> tests = best.getTests();
    boolean allStable = TestStabilityChecker.checkStability(tests);
    assertTrue(allStable);
}
Also used : TestCase(org.evosuite.testcase.TestCase) EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Aggregations

TestCase (org.evosuite.testcase.TestCase)192 Test (org.junit.Test)119 DefaultTestCase (org.evosuite.testcase.DefaultTestCase)90 ArrayList (java.util.ArrayList)67 CoverageGoalTestNameGenerationStrategy (org.evosuite.junit.naming.methods.CoverageGoalTestNameGenerationStrategy)47 MethodCoverageTestFitness (org.evosuite.coverage.method.MethodCoverageTestFitness)45 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)43 IntPrimitiveStatement (org.evosuite.testcase.statements.numeric.IntPrimitiveStatement)39 VariableReference (org.evosuite.testcase.variable.VariableReference)26 OutputCoverageGoal (org.evosuite.coverage.io.output.OutputCoverageGoal)25 OutputCoverageTestFitness (org.evosuite.coverage.io.output.OutputCoverageTestFitness)25 TestFitnessFunction (org.evosuite.testcase.TestFitnessFunction)24 BranchCoverageSuiteFitness (org.evosuite.coverage.branch.BranchCoverageSuiteFitness)17 TestChromosome (org.evosuite.testcase.TestChromosome)17 InstrumentingClassLoader (org.evosuite.instrumentation.InstrumentingClassLoader)15 Ignore (org.junit.Ignore)15 VariableReferenceImpl (org.evosuite.testcase.variable.VariableReferenceImpl)14 GenericMethod (org.evosuite.utils.generic.GenericMethod)12 ExceptionCoverageTestFitness (org.evosuite.coverage.exception.ExceptionCoverageTestFitness)11 InputCoverageGoal (org.evosuite.coverage.io.input.InputCoverageGoal)10