use of org.evosuite.testcase.variable.VariableReferenceImpl in project evosuite by EvoSuite.
the class TestOverloading method testOverloadedConstructor.
@Test
public void testOverloadedConstructor() {
Class<?> clazz = ClassWithOverloadedMethods.class;
Constructor<?> constructor1 = clazz.getConstructors()[0];
Constructor<?> constructor2 = clazz.getConstructors()[1];
GenericConstructor genericConstructor1 = new GenericConstructor(constructor1, clazz);
GenericConstructor genericConstructor2 = new GenericConstructor(constructor2, clazz);
TestCase test = new DefaultTestCase();
ConstantValue intValue = new ConstantValue(test, int.class);
VariableReference integerVar = new VariableReferenceImpl(test, Integer.class);
List<VariableReference> parameters = Arrays.asList(intValue, integerVar);
assertTrue(genericConstructor1.isOverloaded(parameters));
assertTrue(genericConstructor2.isOverloaded(parameters));
}
use of org.evosuite.testcase.variable.VariableReferenceImpl in project evosuite by EvoSuite.
the class TestOverloading method testOverloadedMethod.
@Test
public void testOverloadedMethod() {
Class<?> clazz = ClassWithOverloadedMethods.class;
Method method1 = clazz.getMethods()[0];
Method method2 = clazz.getMethods()[1];
GenericMethod genericMethod1 = new GenericMethod(method1, clazz);
GenericMethod genericMethod2 = new GenericMethod(method2, clazz);
TestCase test = new DefaultTestCase();
ConstantValue intValue = new ConstantValue(test, int.class);
VariableReference integerVar = new VariableReferenceImpl(test, Integer.class);
List<VariableReference> parameters1 = Arrays.asList(intValue);
List<VariableReference> parameters2 = Arrays.asList(integerVar);
assertTrue(genericMethod1.isOverloaded());
assertTrue(genericMethod2.isOverloaded());
assertTrue(genericMethod1.isOverloaded(parameters1));
assertTrue(genericMethod2.isOverloaded(parameters1));
assertTrue(genericMethod1.isOverloaded(parameters2));
assertTrue(genericMethod2.isOverloaded(parameters2));
}
use of org.evosuite.testcase.variable.VariableReferenceImpl in project evosuite by EvoSuite.
the class TestOverloading method testNotOverloadedConstructor.
@Test
public void testNotOverloadedConstructor() {
Class<?> clazz = ClassWithoutOverloadedMethods.class;
Constructor<?> constructor1 = clazz.getConstructors()[0];
Constructor<?> constructor2 = clazz.getConstructors()[1];
GenericConstructor genericConstructor1 = new GenericConstructor(constructor1, clazz);
GenericConstructor genericConstructor2 = new GenericConstructor(constructor2, clazz);
TestCase test = new DefaultTestCase();
ConstantValue intValue = new ConstantValue(test, int.class);
VariableReference stringVar = new VariableReferenceImpl(test, String.class);
List<VariableReference> parameters1 = Arrays.asList(intValue);
List<VariableReference> parameters2 = Arrays.asList(stringVar);
assertFalse(genericConstructor1.isOverloaded(parameters1));
assertFalse(genericConstructor2.isOverloaded(parameters2));
assertFalse(genericConstructor1.isOverloaded(parameters2));
assertFalse(genericConstructor2.isOverloaded(parameters1));
}
use of org.evosuite.testcase.variable.VariableReferenceImpl in project evosuite by EvoSuite.
the class FunctionalMockStatementTest method testPackageLevel_differentPackage_instrumentation_public.
/*
* This test fails when Mockito is instrumented (it would pass if org.mockito. is excluded from instrumentation.
* However, in the packaged version, Mockito is shaded and thus isn't actually instrumented. I don't have a good
* solution to fix this test, hence I've marked it as ignored. (Gordon, 9.2.2018)
*/
@Test
public void testPackageLevel_differentPackage_instrumentation_public() throws Exception {
TestCase tc = new DefaultTestCase();
RuntimeInstrumentation.setAvoidInstrumentingShadedClasses(true);
ClassPathHandler.getInstance().changeTargetCPtoTheSameAsEvoSuite();
InstrumentingClassLoader loader = new InstrumentingClassLoader();
Class<?> example = loader.loadClass("com.examples.with.different.packagename.fm.ExamplePublicLevel");
VariableReference ref = new VariableReferenceImpl(tc, example);
FunctionalMockStatement mockStmt = new FunctionalMockStatement(tc, ref, example);
tc.addStatement(mockStmt);
execute(tc);
}
use of org.evosuite.testcase.variable.VariableReferenceImpl in project evosuite by EvoSuite.
the class FunctionalMockStatementTest method testAll_once.
@Test
public void testAll_once() throws Exception {
TestCase tc = new DefaultTestCase();
VariableReference ref = new VariableReferenceImpl(tc, Foo.class);
FunctionalMockStatement mockStmt = new FunctionalMockStatement(tc, ref, Foo.class);
VariableReference mock = tc.addStatement(mockStmt);
VariableReference result = tc.addStatement(new MethodStatement(tc, new GenericMethod(this.getClass().getDeclaredMethod("all_once", Foo.class), FunctionalMockStatementTest.class), null, Arrays.asList(mock)));
Assert.assertFalse(mockStmt.doesNeedToUpdateInputs());
Assert.assertEquals(0, mockStmt.getNumParameters());
// execute first time with default mock
Scope scope = execute(tc);
Assert.assertTrue(mockStmt.doesNeedToUpdateInputs());
List<Type> types = mockStmt.updateMockedMethods();
Assert.assertEquals(7, types.size());
}
Aggregations