use of org.evosuite.testcase.TestFactory in project evosuite by EvoSuite.
the class LocalSearchNumericSystemTest method getFloatTest.
private TestCase getFloatTest(float x, float y) throws NoSuchMethodException, SecurityException, ConstructionFailedException, ClassNotFoundException {
Class<?> sut = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(Properties.TARGET_CLASS);
GenericClass clazz = new GenericClass(sut);
DefaultTestCase test = new DefaultTestCase();
GenericConstructor gc = new GenericConstructor(clazz.getRawClass().getConstructors()[0], clazz);
TestFactory testFactory = TestFactory.getInstance();
VariableReference callee = testFactory.addConstructor(test, gc, 0, 0);
VariableReference intVar1 = test.addStatement(new FloatPrimitiveStatement(test, x));
VariableReference intVar0 = test.addStatement(new FloatPrimitiveStatement(test, y));
Method m = clazz.getRawClass().getMethod("testMe", new Class<?>[] { float.class, float.class });
GenericMethod method = new GenericMethod(m, sut);
MethodStatement ms = new MethodStatement(test, method, callee, Arrays.asList(new VariableReference[] { intVar0, intVar1 }));
test.addStatement(ms);
return test;
}
use of org.evosuite.testcase.TestFactory in project evosuite by EvoSuite.
the class LocalSearchNumericSystemTest method getIntTest.
private TestCase getIntTest(int x, int y) throws NoSuchMethodException, SecurityException, ConstructionFailedException, ClassNotFoundException {
Class<?> sut = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(Properties.TARGET_CLASS);
GenericClass clazz = new GenericClass(sut);
DefaultTestCase test = new DefaultTestCase();
GenericConstructor gc = new GenericConstructor(clazz.getRawClass().getConstructors()[0], clazz);
TestFactory testFactory = TestFactory.getInstance();
VariableReference callee = testFactory.addConstructor(test, gc, 0, 0);
VariableReference intVar1 = test.addStatement(new IntPrimitiveStatement(test, x));
VariableReference intVar0 = test.addStatement(new IntPrimitiveStatement(test, y));
Method m = clazz.getRawClass().getMethod("testMe", new Class<?>[] { int.class, int.class });
GenericMethod method = new GenericMethod(m, sut);
MethodStatement ms = new MethodStatement(test, method, callee, Arrays.asList(new VariableReference[] { intVar0, intVar1 }));
test.addStatement(ms);
return test;
}
use of org.evosuite.testcase.TestFactory in project evosuite by EvoSuite.
the class LocalSearchNumericSystemTest method getDoubleTest.
private TestCase getDoubleTest(double x, double y) throws NoSuchMethodException, SecurityException, ConstructionFailedException, ClassNotFoundException {
Class<?> sut = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(Properties.TARGET_CLASS);
GenericClass clazz = new GenericClass(sut);
DefaultTestCase test = new DefaultTestCase();
GenericConstructor gc = new GenericConstructor(clazz.getRawClass().getConstructors()[0], clazz);
TestFactory testFactory = TestFactory.getInstance();
VariableReference callee = testFactory.addConstructor(test, gc, 0, 0);
VariableReference intVar1 = test.addStatement(new DoublePrimitiveStatement(test, x));
VariableReference intVar0 = test.addStatement(new DoublePrimitiveStatement(test, y));
Method m = clazz.getRawClass().getMethod("testMe", new Class<?>[] { double.class, double.class });
GenericMethod method = new GenericMethod(m, sut);
MethodStatement ms = new MethodStatement(test, method, callee, Arrays.asList(new VariableReference[] { intVar0, intVar1 }));
test.addStatement(ms);
return test;
}
Aggregations