Search in sources :

Example 21 with InstrumentingClassLoader

use of org.evosuite.instrumentation.InstrumentingClassLoader in project evosuite by EvoSuite.

the class MockJOptionPaneShowMessageDialogTest method testShowMessageDialog1.

@Test
public void testShowMessageDialog1() throws Exception {
    TestSuiteChromosome suite = new TestSuiteChromosome();
    InstrumentingClassLoader cl = new InstrumentingClassLoader();
    TestCase t0 = buildTestCase1TrueBranch(cl);
    TestCase t1 = buildTestCase1FalseBranch(cl);
    suite.addTest(t0);
    suite.addTest(t1);
    BranchCoverageSuiteFitness ff = new BranchCoverageSuiteFitness(cl);
    ff.getFitness(suite);
    Set<TestFitnessFunction> coveredGoals = suite.getCoveredGoals();
    Assert.assertEquals(3, coveredGoals.size());
}
Also used : TestCase(org.evosuite.testcase.TestCase) TestFitnessFunction(org.evosuite.testcase.TestFitnessFunction) BranchCoverageSuiteFitness(org.evosuite.coverage.branch.BranchCoverageSuiteFitness) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) InstrumentingClassLoader(org.evosuite.instrumentation.InstrumentingClassLoader) Test(org.junit.Test)

Example 22 with InstrumentingClassLoader

use of org.evosuite.instrumentation.InstrumentingClassLoader in project evosuite by EvoSuite.

the class MockJOptionPaneShowOptionDialogTest method testShowInputDialogs.

@Test
public void testShowInputDialogs() throws Exception {
    TestSuiteChromosome suite = new TestSuiteChromosome();
    InstrumentingClassLoader cl = new InstrumentingClassLoader();
    TestCase t1 = buildTestCase0(cl);
    suite.addTest(t1);
    BranchCoverageSuiteFitness ff = new BranchCoverageSuiteFitness(cl);
    ff.getFitness(suite);
    Set<TestFitnessFunction> coveredGoals = suite.getCoveredGoals();
    Assert.assertEquals(2, coveredGoals.size());
}
Also used : TestCase(org.evosuite.testcase.TestCase) TestFitnessFunction(org.evosuite.testcase.TestFitnessFunction) BranchCoverageSuiteFitness(org.evosuite.coverage.branch.BranchCoverageSuiteFitness) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) InstrumentingClassLoader(org.evosuite.instrumentation.InstrumentingClassLoader) Test(org.junit.Test)

Example 23 with InstrumentingClassLoader

use of org.evosuite.instrumentation.InstrumentingClassLoader in project evosuite by EvoSuite.

the class MockJOptionPaneTest method testCoveredGoals.

@Test
public void testCoveredGoals() throws Exception {
    Properties.TIMEOUT = Integer.MAX_VALUE;
    InstrumentingClassLoader cl = new InstrumentingClassLoader();
    TestCase t0 = buildTestCase0(cl);
    TestCase t1 = buildTestCase1(cl);
    TestSuiteChromosome suite = new TestSuiteChromosome();
    suite.addTest(t0);
    suite.addTest(t1);
    BranchCoverageSuiteFitness ff = new BranchCoverageSuiteFitness(cl);
    ff.getFitness(suite);
    Set<TestFitnessFunction> coveredGoals = suite.getCoveredGoals();
    Assert.assertEquals(3, coveredGoals.size());
}
Also used : TestCase(org.evosuite.testcase.TestCase) TestFitnessFunction(org.evosuite.testcase.TestFitnessFunction) BranchCoverageSuiteFitness(org.evosuite.coverage.branch.BranchCoverageSuiteFitness) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) InstrumentingClassLoader(org.evosuite.instrumentation.InstrumentingClassLoader) Test(org.junit.Test)

Example 24 with InstrumentingClassLoader

use of org.evosuite.instrumentation.InstrumentingClassLoader in project evosuite by EvoSuite.

the class TestGenericClass method reloadNonArrayClass.

@Test
public void reloadNonArrayClass() {
    GenericClass arrayClass = new GenericClass(Integer.class);
    ClassLoader loader = new InstrumentingClassLoader();
    arrayClass.changeClassLoader(loader);
    Class<?> rawClass = arrayClass.getRawClass();
    Assert.assertFalse(rawClass.isArray());
}
Also used : GenericClass(org.evosuite.utils.generic.GenericClass) InstrumentingClassLoader(org.evosuite.instrumentation.InstrumentingClassLoader) InstrumentingClassLoader(org.evosuite.instrumentation.InstrumentingClassLoader) Test(org.junit.Test)

Example 25 with InstrumentingClassLoader

use of org.evosuite.instrumentation.InstrumentingClassLoader in project evosuite by EvoSuite.

the class TestGenericClass method reloadArrayClass.

@Test
public void reloadArrayClass() {
    GenericClass arrayClass = new GenericClass(Object[].class);
    ClassLoader loader = new InstrumentingClassLoader();
    arrayClass.changeClassLoader(loader);
    Class<?> rawClass = arrayClass.getRawClass();
    Assert.assertTrue(rawClass.isArray());
}
Also used : GenericClass(org.evosuite.utils.generic.GenericClass) InstrumentingClassLoader(org.evosuite.instrumentation.InstrumentingClassLoader) InstrumentingClassLoader(org.evosuite.instrumentation.InstrumentingClassLoader) Test(org.junit.Test)

Aggregations

InstrumentingClassLoader (org.evosuite.instrumentation.InstrumentingClassLoader)26 Test (org.junit.Test)23 TestCase (org.evosuite.testcase.TestCase)15 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)13 BranchCoverageSuiteFitness (org.evosuite.coverage.branch.BranchCoverageSuiteFitness)12 TestFitnessFunction (org.evosuite.testcase.TestFitnessFunction)11 DefaultTestCase (org.evosuite.testcase.DefaultTestCase)5 VariableReference (org.evosuite.testcase.variable.VariableReference)4 GenericClass (org.evosuite.utils.generic.GenericClass)3 ExtendingFile (com.examples.with.different.packagename.mock.java.io.ExtendingFile)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 NonInstrumentingClassLoader (org.evosuite.instrumentation.NonInstrumentingClassLoader)2 MockFile (org.evosuite.runtime.mock.java.io.MockFile)2 VariableReferenceImpl (org.evosuite.testcase.variable.VariableReferenceImpl)2 CBranchExample (com.examples.with.different.packagename.cbranch.CBranchExample)1 MemoryCheck (com.examples.with.different.packagename.mock.java.lang.MemoryCheck)1 TypeToken (com.googlecode.gentyref.TypeToken)1 File (java.io.File)1 Assertion (org.evosuite.assertion.Assertion)1