Search in sources :

Example 1 with TestClasses

use of com.oracle.bedrock.testsupport.junit.options.TestClasses in project oracle-bedrock by coherence-community.

the class TestClassesClassPathClassesTest method shouldLoadJUnit3SuiteClass.

@Test
public void shouldLoadJUnit3SuiteClass() throws Exception {
    File folder = createClassesFolder(JUnit3Suite.class);
    ClassPath classPath = ClassPath.ofFile(folder);
    TestClasses.ClassPathClasses testClasses = new TestClasses.ClassPathClasses(classPath);
    Set<Class<?>> classes = testClasses.resolveTestClasses();
    assertThat(classes, is(notNullValue()));
    assertThat(classes, containsInAnyOrder(JUnit3Suite.class));
}
Also used : TestClasses(com.oracle.bedrock.testsupport.junit.options.TestClasses) JUnit3Suite(com.oracle.bedrock.testsupport.junit.JUnit3Suite) ClassPath(com.oracle.bedrock.runtime.java.ClassPath) File(java.io.File) RunWithAnnotatedTest(com.oracle.bedrock.testsupport.junit.RunWithAnnotatedTest) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) JUnit3Test(com.oracle.bedrock.testsupport.junit.JUnit3Test) Test(org.junit.Test)

Example 2 with TestClasses

use of com.oracle.bedrock.testsupport.junit.options.TestClasses in project oracle-bedrock by coherence-community.

the class TestClassesClassPathClassesTest method shouldLoadJUnit4TestClass.

@Test
public void shouldLoadJUnit4TestClass() throws Exception {
    File folder = createClassesFolder(JUnit4Test.class);
    ClassPath classPath = ClassPath.ofFile(folder);
    TestClasses.ClassPathClasses testClasses = new TestClasses.ClassPathClasses(classPath);
    Set<Class<?>> classes = testClasses.resolveTestClasses();
    assertThat(classes, is(notNullValue()));
    assertThat(classes, containsInAnyOrder(JUnit4Test.class));
}
Also used : TestClasses(com.oracle.bedrock.testsupport.junit.options.TestClasses) ClassPath(com.oracle.bedrock.runtime.java.ClassPath) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) File(java.io.File) RunWithAnnotatedTest(com.oracle.bedrock.testsupport.junit.RunWithAnnotatedTest) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) JUnit3Test(com.oracle.bedrock.testsupport.junit.JUnit3Test) Test(org.junit.Test)

Example 3 with TestClasses

use of com.oracle.bedrock.testsupport.junit.options.TestClasses in project oracle-bedrock by coherence-community.

the class TestClassesClassPathClassesTest method shouldNotLoadAbstractClass.

@Test
public void shouldNotLoadAbstractClass() throws Exception {
    File folder = createClassesFolder(AbstractJUnit4Test.class);
    ClassPath classPath = ClassPath.ofFile(folder);
    TestClasses.ClassPathClasses testClasses = new TestClasses.ClassPathClasses(classPath);
    Set<Class<?>> classes = testClasses.resolveTestClasses();
    assertThat(classes, is(notNullValue()));
    assertThat(classes.isEmpty(), is(true));
}
Also used : TestClasses(com.oracle.bedrock.testsupport.junit.options.TestClasses) ClassPath(com.oracle.bedrock.runtime.java.ClassPath) File(java.io.File) RunWithAnnotatedTest(com.oracle.bedrock.testsupport.junit.RunWithAnnotatedTest) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) JUnit3Test(com.oracle.bedrock.testsupport.junit.JUnit3Test) Test(org.junit.Test)

Example 4 with TestClasses

use of com.oracle.bedrock.testsupport.junit.options.TestClasses in project oracle-bedrock by coherence-community.

the class TestClassesClassPathClassesTest method shouldLoadRunWithAnnotatedTestClassFromJar.

@Test
public void shouldLoadRunWithAnnotatedTestClassFromJar() throws Exception {
    File jar = createJar(RunWithAnnotatedTest.class);
    ClassPath classPath = ClassPath.ofFile(jar);
    TestClasses.ClassPathClasses testClasses = new TestClasses.ClassPathClasses(classPath);
    Set<Class<?>> classes = testClasses.resolveTestClasses();
    assertThat(classes, is(notNullValue()));
    assertThat(classes, containsInAnyOrder(RunWithAnnotatedTest.class));
}
Also used : TestClasses(com.oracle.bedrock.testsupport.junit.options.TestClasses) RunWithAnnotatedTest(com.oracle.bedrock.testsupport.junit.RunWithAnnotatedTest) ClassPath(com.oracle.bedrock.runtime.java.ClassPath) File(java.io.File) RunWithAnnotatedTest(com.oracle.bedrock.testsupport.junit.RunWithAnnotatedTest) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) JUnit3Test(com.oracle.bedrock.testsupport.junit.JUnit3Test) Test(org.junit.Test)

Example 5 with TestClasses

use of com.oracle.bedrock.testsupport.junit.options.TestClasses in project oracle-bedrock by coherence-community.

the class JUnitTestRunner method runTests.

/**
 * Run the tests specified by the given {@link OptionsByType}.
 *
 * @param optionsByType  the {@link OptionsByType} controlling the test run
 */
private void runTests(OptionsByType optionsByType) {
    // If the options are null there is nothing to do
    if (optionsByType == null) {
        return;
    }
    Tests tests = optionsByType.get(Tests.class);
    // If there are no tests to execute then return
    if (tests.isEmpty()) {
        return;
    }
    JUnitCore jUnitCore = new JUnitCore();
    Result result = new Result();
    Listener listener = new Listener();
    jUnitCore.addListener(result.createListener());
    jUnitCore.addListener(listener);
    for (RunListener runListener : optionsByType.getInstancesOf(RunListener.class)) {
        jUnitCore.addListener(runListener);
    }
    // Run the tests in each TestClasses instance
    for (TestClasses testClasses : tests) {
        Set<Class<?>> classes = testClasses.resolveTestClasses();
        Filter filter = testClasses.getTestFilter();
        for (Class<?> testClass : classes) {
            Request request = Request.aClass(testClass);
            if (filter != null) {
                request = request.filterWith(filter);
            }
            jUnitCore.run(request);
            // If the state has changed to stopped then we should exit
            if (state == State.Stopped) {
                return;
            }
        }
    }
}
Also used : TestClasses(com.oracle.bedrock.testsupport.junit.options.TestClasses) RunListener(org.junit.runner.notification.RunListener) JUnitCore(org.junit.runner.JUnitCore) Filter(org.junit.runner.manipulation.Filter) Request(org.junit.runner.Request) Tests(com.oracle.bedrock.testsupport.junit.options.Tests) Result(org.junit.runner.Result) RunListener(org.junit.runner.notification.RunListener)

Aggregations

TestClasses (com.oracle.bedrock.testsupport.junit.options.TestClasses)21 Test (org.junit.Test)20 JUnit4Test (com.oracle.bedrock.testsupport.junit.JUnit4Test)16 AbstractJUnit4Test (com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test)12 File (java.io.File)11 ClassPath (com.oracle.bedrock.runtime.java.ClassPath)10 JUnit3Test (com.oracle.bedrock.testsupport.junit.JUnit3Test)9 RunWithAnnotatedTest (com.oracle.bedrock.testsupport.junit.RunWithAnnotatedTest)9 MyOtherTest (com.oracle.bedrock.testsupport.junit.MyOtherTest)7 OptionsByType (com.oracle.bedrock.OptionsByType)4 Tests (com.oracle.bedrock.testsupport.junit.options.Tests)4 JUnitTestRun (com.oracle.bedrock.testsupport.junit.JUnitTestRun)3 MyBadTest (com.oracle.bedrock.testsupport.junit.MyBadTest)3 SimpleJUnitTestListener (com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener)3 JUnit3Suite (com.oracle.bedrock.testsupport.junit.JUnit3Suite)2 Platform (com.oracle.bedrock.runtime.Platform)1 RemoteCallable (com.oracle.bedrock.runtime.concurrent.RemoteCallable)1 JavaApplicationProcess (com.oracle.bedrock.runtime.java.JavaApplicationProcess)1 JUnitTestRunner (com.oracle.bedrock.testsupport.junit.JUnitTestRunner)1 JUnitTextReporter (com.oracle.bedrock.testsupport.junit.JUnitTextReporter)1