use of fr.inria.stamp.test.listener.TestListener in project dspot by STAMP-project.
the class TestLauncherTest method testLauncherOnTestThatUseSystemProperties.
@Test
public void testLauncherOnTestThatUseSystemProperties() throws Exception {
/*
Contract: DSpot is able to run a test that use System Properties.
System Properties must be described in the properties file given as input.
System Properties must be described with the key systemProperties (i.e. systemProperties=...)
System Properties must be a couple of key and value, separated by an equals '=' (e.g. key=value)
System Properties must be separated by a comma ',' (e.g. key1=value1,key2=value2)
*/
Utils.init("src/test/resources/sample/sample.properties");
final CtClass aClass = Utils.findClass("fr.inria.systemproperties.SystemPropertiesTest");
final String classPath = AmplificationHelper.getClassPath(Utils.getCompiler(), Utils.getInputConfiguration());
final TestListener run = TestLauncher.run(Utils.getInputConfiguration(), classPath, aClass);
assertEquals(1, run.getPassingTests().size());
assertEquals(1, run.getRunningTests().size());
assertEquals(0, run.getFailingTests().size());
assertTrue(run.getFailingTests().isEmpty());
}
use of fr.inria.stamp.test.listener.TestListener in project dspot by STAMP-project.
the class TestLauncherTest method testLauncherWithResources.
@Test
public void testLauncherWithResources() throws Exception {
Utils.init("src/test/resources/project-with-resources/project-with-resources.properties");
final CtClass aClass = Utils.findClass("resolver.ClasspathResolverTest");
final String classPath = AmplificationHelper.getClassPath(Utils.getCompiler(), Utils.getInputConfiguration());
final TestListener run = TestLauncher.run(Utils.getInputConfiguration(), classPath, aClass);
assertEquals(10, run.getPassingTests().size());
assertEquals(10, run.getRunningTests().size());
assertTrue(run.getFailingTests().isEmpty());
}
use of fr.inria.stamp.test.listener.TestListener in project dspot by STAMP-project.
the class TestLauncherTest method testLauncherOnTestUsingReflectiveTestRunnerOnTestThatUseSystemProperty.
@Test
public void testLauncherOnTestUsingReflectiveTestRunnerOnTestThatUseSystemProperty() throws Exception {
/*
Using the ReflectiveTestRunner
*/
TestRunnerFactory.useReflectiveTestRunner = true;
Utils.init("src/test/resources/sample/sample.properties");
final CtClass aClass = Utils.findClass("fr.inria.systemproperties.SystemPropertiesTest");
final String classPath = AmplificationHelper.getClassPath(Utils.getCompiler(), Utils.getInputConfiguration());
final TestListener run = TestLauncher.run(Utils.getInputConfiguration(), classPath, aClass);
assertEquals(1, run.getPassingTests().size());
assertEquals(1, run.getRunningTests().size());
assertEquals(0, run.getFailingTests().size());
assertTrue(run.getFailingTests().isEmpty());
TestRunnerFactory.useReflectiveTestRunner = false;
}
use of fr.inria.stamp.test.listener.TestListener in project dspot by STAMP-project.
the class TestLauncherTest method testOnEasyMock.
@Test
public void testOnEasyMock() throws Exception {
try {
FileUtils.deleteDirectory(new File("src/test/resources/easymock/target/"));
} catch (Exception ignored) {
}
Utils.init("src/test/resources/easymock/mock.properties");
final String classpath = AutomaticBuilderFactory.getAutomaticBuilder(Utils.getInputConfiguration()).buildClasspath(Utils.getInputProgram().getProgramDir()) + System.getProperty("path.separator") + Utils.getInputProgram().getProgramDir() + "/" + Utils.getInputProgram().getClassesDir() + System.getProperty("path.separator") + Utils.getInputProgram().getProgramDir() + "/" + Utils.getInputProgram().getTestClassesDir();
final CtClass<?> easyMockTest = Utils.findClass("org.baeldung.mocks.easymock.LoginControllerIntegrationTest");
TestListener run = TestLauncher.run(Utils.getInputConfiguration(), classpath, easyMockTest);
assertEquals(7, run.getRunningTests().size());
assertEquals(7, run.getPassingTests().size());
assertEquals(0, run.getFailingTests().size());
}
use of fr.inria.stamp.test.listener.TestListener in project dspot by STAMP-project.
the class TestLauncherTest method testFromSpoonNodes.
@Test
public void testFromSpoonNodes() throws Exception {
Launcher launcher = new Launcher();
launcher.getEnvironment().setSourceClasspath(System.getProperty("java.class.path").split(System.getProperty("path.separator")));
launcher.addInputResource("src/test/resources/src/");
launcher.addInputResource("src/test/resources/test/");
launcher.buildModel();
final String classpath = "src/test/resources/MockitoDemo-1.0-SNAPSHOT.jar" + System.getProperty("path.separator") + "src/test/resources/MockitoDemo-1.0-SNAPSHOT-tests.jar" + System.getProperty("path.separator") + "src/test/resources/example-0.0.1-SNAPSHOT.jar" + System.getProperty("path.separator") + "src/test/resources/example-0.0.1-SNAPSHOT-tests.jar";
/*
Test that we the same entry point we are able to run all kind of test
*/
InputConfiguration configuration = new InputConfiguration("src/test/resources/mockito/mockito.properties");
configuration.setInputProgram(new InputProgram());
// Mocked
TestListener results = TestLauncher.runFromSpoonNodes(configuration, classpath, launcher.getFactory().Class().get("info.sanaulla.dal.BookDALTest"), launcher.getFactory().Class().get("info.sanaulla.dal.BookDALTest").getMethodsByName("testGetBook"));
assertEquals(1, results.getRunningTests().size());
assertEquals(0, results.getFailingTests().size());
assertEquals(1, results.getPassingTests().size());
assertEquals(0, results.getAssumptionFailingTests().size());
assertEquals(0, results.getIgnoredTests().size());
configuration = new InputConfiguration("src/test/resources/test-projects/test-projects.properties");
configuration.setInputProgram(new InputProgram());
// Default
results = TestLauncher.runFromSpoonNodes(configuration, classpath, launcher.getFactory().Class().get("example.TestSuiteExample"), launcher.getFactory().Class().get("example.TestSuiteExample").getMethodsByName("test1"));
assertEquals(1, results.getRunningTests().size());
assertEquals(1, results.getFailingTests().size());
assertEquals(0, results.getPassingTests().size());
assertEquals(0, results.getAssumptionFailingTests().size());
assertEquals(0, results.getIgnoredTests().size());
configuration = new InputConfiguration("src/test/resources/sample/sample.properties");
configuration.setInputProgram(new InputProgram());
// will use example.InheriteTest to run the test of AbstractTest
results = TestLauncher.runFromSpoonNodes(configuration, classpath, launcher.getFactory().Class().get("example.AbstractTest"), launcher.getFactory().Class().get("example.AbstractTest").getMethodsByName("abstractTest"));
assertEquals(1, results.getRunningTests().size());
assertEquals(0, results.getFailingTests().size());
assertEquals(1, results.getPassingTests().size());
assertEquals(0, results.getAssumptionFailingTests().size());
assertEquals(0, results.getIgnoredTests().size());
}
Aggregations