use of org.junit.runner.notification.RunNotifier in project mockito by mockito.
the class ConsoleSpammingMockitoJUnitRunnerTest method setup.
@Before
public void setup() throws InitializationError {
loggerStub = new MockitoLoggerStub();
notifier = new RunNotifier();
}
use of org.junit.runner.notification.RunNotifier in project gradle by gradle.
the class JUnitTestClassExecuter method runTestClass.
private void runTestClass(String testClassName) throws ClassNotFoundException {
final Class<?> testClass = Class.forName(testClassName, false, applicationClassLoader);
List<Filter> filters = new ArrayList<Filter>();
if (options.hasCategoryConfiguration()) {
verifyJUnitCategorySupport();
Transformer<Class<?>, String> transformer = new Transformer<Class<?>, String>() {
public Class<?> transform(final String original) {
try {
return applicationClassLoader.loadClass(original);
} catch (ClassNotFoundException e) {
throw new InvalidUserDataException(String.format("Can't load category class [%s].", original), e);
}
}
};
filters.add(new CategoryFilter(CollectionUtils.collect(options.getIncludeCategories(), transformer), CollectionUtils.collect(options.getExcludeCategories(), transformer)));
}
Request request = Request.aClass(testClass);
Runner runner = request.getRunner();
if (!options.getIncludedTests().isEmpty()) {
TestSelectionMatcher matcher = new TestSelectionMatcher(options.getIncludedTests());
// matches the filter, run the entire suite instead of filtering away its contents.
if (!runner.getDescription().isSuite() || !matcher.matchesTest(testClassName, null)) {
filters.add(new MethodNameFilter(matcher));
}
}
if (runner instanceof Filterable) {
Filterable filterable = (Filterable) runner;
for (Filter filter : filters) {
try {
filterable.filter(filter);
} catch (NoTestsRemainException e) {
// Ignore
return;
}
}
} else if (allTestsFiltered(runner, filters)) {
return;
}
RunNotifier notifier = new RunNotifier();
notifier.addListener(listener);
runner.run(notifier);
}
use of org.junit.runner.notification.RunNotifier in project drools by kiegroup.
the class ScenarioRunner4JUnitTest method testBasic.
@Test
public void testBasic() throws Exception {
HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
ksessions.put("someId", ksession);
Scenario scenario = new Scenario();
scenario.getKSessions().add("someId");
ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(scenario, ksessions);
RunNotifier notifier = new RunNotifier();
RunListener runListener = spy(new RunListener());
notifier.addListener(runListener);
runner4JUnit.run(notifier);
verify(runListener, never()).testFailure(any(Failure.class));
verify(runListener).testFinished(any(Description.class));
verify(ksession).reset();
}
use of org.junit.runner.notification.RunNotifier in project drools by kiegroup.
the class ScenarioRunner4JUnitTest method testIDNotSet.
@Test
public void testIDNotSet() throws Exception {
HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
ksessions.put(null, ksession);
ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(new Scenario(), ksessions);
RunNotifier notifier = new RunNotifier();
RunListener runListener = spy(new RunListener());
notifier.addListener(runListener);
runner4JUnit.run(notifier);
verify(runListener, never()).testFailure(any(Failure.class));
verify(runListener).testFinished(any(Description.class));
verify(ksession).reset();
}
use of org.junit.runner.notification.RunNotifier in project drools by kiegroup.
the class ScenarioRunner4JUnitTest method testNoKieSession.
@Test
public void testNoKieSession() throws Exception {
ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(new Scenario(), new HashMap<String, KieSession>());
RunNotifier notifier = new RunNotifier();
RunListener runListener = spy(new RunListener());
notifier.addListener(runListener);
runner4JUnit.run(notifier);
verify(runListener).testFailure(any(Failure.class));
}
Aggregations