Search in sources :

Example 11 with InstrumentingClassLoader

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

the class MockJOptionPaneShowMessageDialogTest method testShowMessageDialog0.

@Test
public void testShowMessageDialog0() throws Exception {
    TestSuiteChromosome suite = new TestSuiteChromosome();
    InstrumentingClassLoader cl = new InstrumentingClassLoader();
    TestCase t0 = buildTestCase0TrueBranch(cl);
    TestCase t1 = buildTestCase0FalseBranch(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 12 with InstrumentingClassLoader

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

the class MockJOptionPaneShowMessageDialogTest method testShowMessageDialog2.

@Test
public void testShowMessageDialog2() throws Exception {
    TestSuiteChromosome suite = new TestSuiteChromosome();
    InstrumentingClassLoader cl = new InstrumentingClassLoader();
    TestCase t0 = buildTestCase2TrueBranch(cl);
    TestCase t1 = buildTestCase2FalseBranch(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 13 with InstrumentingClassLoader

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

the class MockJOptionPaneTest method testShowInputDialogWasFound.

@Test
public void testShowInputDialogWasFound() throws Exception {
    boolean hasStringDialog0 = JOptionPaneInputs.getInstance().hasDialog(GUIAction.STRING_INPUT);
    assertFalse(hasStringDialog0);
    InstrumentingClassLoader cl = new InstrumentingClassLoader();
    TestCase t1 = buildTestCase0(cl);
    TestCaseExecutor.getInstance().execute(t1);
    boolean hasStringDialog = JOptionPaneInputs.getInstance().hasDialog(GUIAction.STRING_INPUT);
    assertTrue(hasStringDialog);
}
Also used : TestCase(org.evosuite.testcase.TestCase) InstrumentingClassLoader(org.evosuite.instrumentation.InstrumentingClassLoader) Test(org.junit.Test)

Example 14 with InstrumentingClassLoader

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

the class MockJOptionPaneTest method testInlinerBug.

@Test
public void testInlinerBug() 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);
    System.out.println(suite.toString());
    BranchCoverageSuiteFitness ff = new BranchCoverageSuiteFitness(cl);
    ff.getFitness(suite);
    ConstantInliner inliner = new ConstantInliner();
    inliner.inline(suite);
    System.out.println(suite.toString());
    List<ExecutionResult> execResults = suite.getLastExecutionResults();
    assertEquals(2, execResults.size());
    ExecutionResult r1 = execResults.get(0);
    ExecutionResult r2 = execResults.get(1);
    r1.calledReflection();
    r2.calledReflection();
}
Also used : ConstantInliner(org.evosuite.testcase.ConstantInliner) TestCase(org.evosuite.testcase.TestCase) BranchCoverageSuiteFitness(org.evosuite.coverage.branch.BranchCoverageSuiteFitness) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) ExecutionResult(org.evosuite.testcase.execution.ExecutionResult) InstrumentingClassLoader(org.evosuite.instrumentation.InstrumentingClassLoader) Test(org.junit.Test)

Example 15 with InstrumentingClassLoader

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

the class ParentReplacementTest method testWithVFS.

@Test
public void testWithVFS() throws ClassNotFoundException {
    RuntimeSettings.useVFS = true;
    Properties.VIRTUAL_FS = true;
    InstrumentingClassLoader cl = new InstrumentingClassLoader();
    Class<?> clazz = cl.loadClass(ExtendingFile.class.getCanonicalName());
    Class<?> parent = clazz.getSuperclass();
    Assert.assertEquals(MockFile.class.getCanonicalName(), parent.getCanonicalName());
}
Also used : MockFile(org.evosuite.runtime.mock.java.io.MockFile) ExtendingFile(com.examples.with.different.packagename.mock.java.io.ExtendingFile) 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