use of org.junit.runner.Description in project verify-hub by alphagov.
the class InfinispanJunitRunner method run.
@Override
public void run(final RunNotifier notifier) {
notifier.addListener(new RunListener() {
@Override
public void testStarted(Description description) throws Exception {
super.testStarted(description);
}
@Override
public void testFinished(Description description) throws Exception {
super.testFinished(description);
EMBEDDED_CACHE_MANAGER.getCache("state_cache").clear();
EMBEDDED_CACHE_MANAGER.getCache("assertion_id_cache").clear();
}
});
super.run(notifier);
}
use of org.junit.runner.Description in project gradle by gradle.
the class IgnoredTestDescriptorProvider method getAllDescriptions.
List<Description> getAllDescriptions(Description description, String className) {
final AllExceptIgnoredTestRunnerBuilder allExceptIgnoredTestRunnerBuilder = new AllExceptIgnoredTestRunnerBuilder();
try {
final Class<?> testClass = description.getClass().getClassLoader().loadClass(className);
Runner runner = allExceptIgnoredTestRunnerBuilder.runnerForClass(testClass);
if (runner == null) {
// fall back to default runner
runner = Request.aClass(testClass).getRunner();
}
final Description runnerDescription = runner.getDescription();
return runnerDescription.getChildren();
} catch (Throwable throwable) {
throw new TestSuiteExecutionException(String.format("Unable to process Ignored class %s.", className), throwable);
}
}
use of org.junit.runner.Description in project drools by kiegroup.
the class ScenarioRunner4JUnit method runScenario.
private void runScenario(RunNotifier notifier, Scenario scenario) {
Description childDescription = Description.createTestDescription(getClass(), scenario.getName());
descr.addChild(childDescription);
EachTestNotifier eachNotifier = new EachTestNotifier(notifier, childDescription);
try {
eachNotifier.fireTestStarted();
// If a KieSession is not available, fail fast
if (ksessions == null || ksessions.values().isEmpty()) {
eachNotifier.addFailure(new NullKieSessionException("Unable to get a Session to run tests. Check the project for build errors."));
} else {
KieSession ksession = getKSession(scenario.getKSessions());
if (ksession == null) {
String ksessionName = getKSessionName(scenario.getKSessions());
if (ksessionName == null) {
eachNotifier.addFailure(new NullPointerException("Test scenario runner could not find the default knowledge session."));
} else {
eachNotifier.addFailure(new NullPointerException("Test Scenarios require Stateful KieSession to run."));
}
} else {
final ScenarioRunner runner = new ScenarioRunner(ksession, maxRuleFirings);
runner.run(scenario);
if (!scenario.wasSuccessful()) {
StringBuilder builder = new StringBuilder();
for (String message : scenario.getFailureMessages()) {
builder.append(message).append("\n");
}
eachNotifier.addFailedAssumption(new AssumptionViolatedException(builder.toString()));
}
// FLUSSSSSH!
for (FactHandle factHandle : ksession.getFactHandles()) {
ksession.delete(factHandle);
}
resetKieSession(ksession);
}
}
} catch (Throwable t) {
eachNotifier.addFailure(t);
} finally {
// has to always be called as per junit docs
eachNotifier.fireTestFinished();
}
}
use of org.junit.runner.Description in project drools by kiegroup.
the class TestServiceImpl method reportUnrecoverableError.
private void reportUnrecoverableError(String message, RunListener listener, Exception e) {
try {
Description description = Description.createSuiteDescription(message);
listener.testFailure(new Failure(description, e));
} catch (Exception e2) {
// intentionally left empty as there is nothing to do
}
}
use of org.junit.runner.Description in project serenity-jbehave by serenity-bdd.
the class JUnitDescriptionGenerator method descriptionFor.
private Optional<Description> descriptionFor(PerformableStory performableStory) {
List<Description> scenarioDescriptions = getScenarioDescriptions(performableStory.getScenarios());
if (!scenarioDescriptions.isEmpty()) {
Description storyDescription = createDescriptionForStory(performableStory.getStory());
addBeforeOrAfterStep(Stage.BEFORE, beforeOrAfterStory, storyDescription, BEFORE_STORY_STEP_NAME);
for (Description scenarioDescription : scenarioDescriptions) {
storyDescription.addChild(scenarioDescription);
}
addBeforeOrAfterStep(Stage.AFTER, beforeOrAfterStory, storyDescription, AFTER_STORY_STEP_NAME);
return Optional.of(storyDescription);
} else {
return Optional.empty();
}
}
Aggregations