use of com.oracle.bedrock.testsupport.junit.options.Tests 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;
}
}
}
}
use of com.oracle.bedrock.testsupport.junit.options.Tests in project oracle-bedrock by coherence-community.
the class TestsTest method shouldWorkAsAnOption.
@Test
public void shouldWorkAsAnOption() throws Exception {
TestClasses tests = TestClasses.of(JUnit4Test.class);
OptionsByType optionsByType = OptionsByType.of(tests);
Tests result = optionsByType.get(Tests.class);
assertThat(result, is(notNullValue()));
assertThat(result, contains(tests));
}
use of com.oracle.bedrock.testsupport.junit.options.Tests in project oracle-bedrock by coherence-community.
the class TestsTest method shouldAddMultipleSpecifiedTestClasses.
@Test
public void shouldAddMultipleSpecifiedTestClasses() throws Exception {
TestClasses first = TestClasses.of(JUnit4Test.class);
TestClasses second = TestClasses.of(MyOtherTest.class);
OptionsByType optionsByType = OptionsByType.of(first, second);
Tests result = optionsByType.get(Tests.class);
assertThat(result, is(notNullValue()));
assertThat(result, contains(first, second));
}
use of com.oracle.bedrock.testsupport.junit.options.Tests in project oracle-bedrock by coherence-community.
the class TestsTest method shouldRemoveSpecificTestClass.
@Test
public void shouldRemoveSpecificTestClass() throws Exception {
TestClasses first = TestClasses.of(JUnit4Test.class);
TestClasses second = TestClasses.of(MyOtherTest.class);
OptionsByType optionsByType = OptionsByType.of(first, second);
optionsByType.remove(TestClasses.of(JUnit4Test.class));
Tests result = optionsByType.get(Tests.class);
assertThat(result, is(notNullValue()));
assertThat(result, contains(second));
}
use of com.oracle.bedrock.testsupport.junit.options.Tests in project oracle-bedrock by coherence-community.
the class TestsTest method shouldHaveEmptyTestsAsDefaultOption.
@Test
public void shouldHaveEmptyTestsAsDefaultOption() throws Exception {
OptionsByType optionsByType = OptionsByType.empty();
Tests result = optionsByType.get(Tests.class);
assertThat(result, is(notNullValue()));
assertThat(result.iterator().hasNext(), is(false));
}
Aggregations