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));
}
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));
}
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));
}
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));
}
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;
}
}
}
}
Aggregations