Search in sources :

Example 76 with TestCaseBuilder

use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.

the class MockJOptionPaneShowMessageDialogTest method buildTestCase1TrueBranch.

private static TestCase buildTestCase1TrueBranch(InstrumentingClassLoader cl) throws ClassNotFoundException, NoSuchMethodException, SecurityException {
    TestCaseBuilder builder = new TestCaseBuilder();
    Class<?> clazz = cl.loadClass(ShowMessageDialogExample.class.getCanonicalName());
    Constructor<?> constructor = clazz.getConstructor();
    VariableReference showMessageDialogExample0 = builder.appendConstructor(constructor);
    VariableReference int0 = builder.appendIntPrimitive(0);
    Method showMessageDialogMethod = clazz.getMethod("showMessageDialog1", int.class);
    builder.appendMethod(showMessageDialogExample0, showMessageDialogMethod, int0);
    return builder.getDefaultTestCase();
}
Also used : ShowMessageDialogExample(com.examples.with.different.packagename.mock.javax.swing.ShowMessageDialogExample) TestCaseBuilder(org.evosuite.symbolic.TestCaseBuilder) VariableReference(org.evosuite.testcase.variable.VariableReference) Method(java.lang.reflect.Method)

Example 77 with TestCaseBuilder

use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.

the class MockJOptionPaneShowOptionDialogTest method buildTestCase0.

private static TestCase buildTestCase0(InstrumentingClassLoader cl) throws ClassNotFoundException, NoSuchMethodException, SecurityException {
    TestCaseBuilder builder = new TestCaseBuilder();
    Class<?> clazz = cl.loadClass(ShowOptionDialogExample.class.getCanonicalName());
    Constructor<?> constructor = clazz.getConstructor();
    VariableReference showMessageDialogExample0 = builder.appendConstructor(constructor);
    Method showOptionDialogMethod = clazz.getMethod("showOptionDialog");
    builder.appendMethod(showMessageDialogExample0, showOptionDialogMethod);
    return builder.getDefaultTestCase();
}
Also used : TestCaseBuilder(org.evosuite.symbolic.TestCaseBuilder) VariableReference(org.evosuite.testcase.variable.VariableReference) ShowOptionDialogExample(com.examples.with.different.packagename.mock.javax.swing.ShowOptionDialogExample) Method(java.lang.reflect.Method)

Example 78 with TestCaseBuilder

use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.

the class MockJOptionPaneTest method buildTestCase0.

private static TestCase buildTestCase0(InstrumentingClassLoader cl) throws ClassNotFoundException, NoSuchMethodException, SecurityException {
    TestCaseBuilder builder = new TestCaseBuilder();
    Class<?> clazz = cl.loadClass(TARGET_CLASS);
    Constructor<?> constructor = clazz.getConstructor();
    VariableReference showMessageDialogExample0 = builder.appendConstructor(constructor);
    Method showConfirmDialogsMethod = clazz.getMethod("ask");
    builder.appendMethod(showMessageDialogExample0, showConfirmDialogsMethod);
    return builder.getDefaultTestCase();
}
Also used : TestCaseBuilder(org.evosuite.symbolic.TestCaseBuilder) VariableReference(org.evosuite.testcase.variable.VariableReference) Method(java.lang.reflect.Method)

Example 79 with TestCaseBuilder

use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.

the class TestDefaultValue method testShort.

@Test
public void testShort() throws SecurityException, NoSuchMethodException {
    TestCaseBuilder builder = new TestCaseBuilder();
    ArrayReference integerArray0 = builder.appendArrayStmt(Short[].class, 10);
    VariableReference integer0 = builder.appendNull(Short.class);
    builder.appendAssignment(integerArray0, 0, integer0);
    builder.appendAssignment(integer0, integerArray0, 0);
    builder.appendMethod(integer0, Short.class.getMethod("toString"));
    DefaultTestCase tc = builder.getDefaultTestCase();
    ExecutionResult ret_val = TestCaseExecutor.runTest(tc);
    assertNotNull(ret_val);
    assertFalse(ret_val.explicitExceptions.isEmpty());
}
Also used : ArrayReference(org.evosuite.testcase.variable.ArrayReference) TestCaseBuilder(org.evosuite.symbolic.TestCaseBuilder) VariableReference(org.evosuite.testcase.variable.VariableReference) ExecutionResult(org.evosuite.testcase.execution.ExecutionResult) DefaultTestCase(org.evosuite.testcase.DefaultTestCase) Test(org.junit.Test)

Example 80 with TestCaseBuilder

use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.

the class TestDefaultValue method testInteger.

@Test
public void testInteger() throws SecurityException, NoSuchMethodException {
    TestCaseBuilder builder = new TestCaseBuilder();
    ArrayReference integerArray0 = builder.appendArrayStmt(Integer[].class, 10);
    VariableReference integer0 = builder.appendNull(Integer.class);
    builder.appendAssignment(integerArray0, 0, integer0);
    builder.appendAssignment(integer0, integerArray0, 0);
    builder.appendMethod(integer0, Integer.class.getMethod("toString"));
    DefaultTestCase tc = builder.getDefaultTestCase();
    ExecutionResult ret_val = TestCaseExecutor.runTest(tc);
    assertNotNull(ret_val);
    assertFalse(ret_val.explicitExceptions.isEmpty());
}
Also used : ArrayReference(org.evosuite.testcase.variable.ArrayReference) TestCaseBuilder(org.evosuite.symbolic.TestCaseBuilder) VariableReference(org.evosuite.testcase.variable.VariableReference) ExecutionResult(org.evosuite.testcase.execution.ExecutionResult) DefaultTestCase(org.evosuite.testcase.DefaultTestCase) Test(org.junit.Test)

Aggregations

TestCaseBuilder (org.evosuite.symbolic.TestCaseBuilder)146 VariableReference (org.evosuite.testcase.variable.VariableReference)143 Method (java.lang.reflect.Method)129 Test (org.junit.Test)16 DowncastExample (com.examples.with.different.packagename.test.DowncastExample)8 DefaultTestCase (org.evosuite.testcase.DefaultTestCase)8 ExecutionResult (org.evosuite.testcase.execution.ExecutionResult)7 ArrayReference (org.evosuite.testcase.variable.ArrayReference)7 MIMEType (com.examples.with.different.packagename.concolic.MIMEType)6 ShowMessageDialogExample (com.examples.with.different.packagename.mock.javax.swing.ShowMessageDialogExample)6 Field (java.lang.reflect.Field)6 ConcreteSubclass (com.examples.with.different.packagename.test.ConcreteSubclass)4 ShowInternalMessageDialogExample (com.examples.with.different.packagename.mock.javax.swing.ShowInternalMessageDialogExample)2 AbstractSuperclass (com.examples.with.different.packagename.test.AbstractSuperclass)2 AssignmentStatement (org.evosuite.testcase.statements.AssignmentStatement)2 FieldReference (org.evosuite.testcase.variable.FieldReference)2 GenericField (org.evosuite.utils.generic.GenericField)2 CBranchExample (com.examples.with.different.packagename.cbranch.CBranchExample)1 ShowConfirmDialogExample (com.examples.with.different.packagename.mock.javax.swing.ShowConfirmDialogExample)1 ShowInputDialogExample (com.examples.with.different.packagename.mock.javax.swing.ShowInputDialogExample)1