use of org.junit.runners.model.InitializationError in project st-js by st-js.
the class JUnitSession method init.
/**
* Starts all the browser and server sessions. If the sessions are already started, this method has no effect.
*
* @throws InitializationError
*/
private void init(Class<?> testClassSample) throws InitializationError {
if (config != null) {
// init has already been called, nothing to do
return;
}
if (this.initFailed) {
throw new InitializationError("Session initialization failed previously. Not trying again.");
}
try {
config = new DriverConfiguration(testClassSample);
addShutdownHook();
// initialize the browser sessions
initBrowsers();
initBrowserDependencies();
startBrowserDependencies();
startBrowsers();
} catch (Throwable e) {
printStackTrace(e);
reset();
this.initFailed = true;
// sometimes, JUnit doesn't display the exception, so let's print it out
throw new InitializationError(e);
}
}
use of org.junit.runners.model.InitializationError in project st-js by st-js.
the class JUnitSession method printCauses.
private static void printCauses(Throwable caused, String prefix, PrintStream out) {
if (caused instanceof InitializationError) {
// Initialization error does not use the standard way to report causes, and therefore
// printStackTrace() on InitializationError does not print causes. Let's try to fix that
InitializationError ie = (InitializationError) caused;
List<Throwable> causes = ie.getCauses();
if (causes != null && !causes.isEmpty()) {
System.err.println(prefix + "Caused by " + causes.size() + " exceptions:");
for (Throwable cause : causes) {
printCauseStackTrace(cause, caused.getStackTrace(), "\t" + prefix, out);
}
}
} else if (caused.getCause() != null) {
printCauseStackTrace(caused.getCause(), caused.getStackTrace(), prefix, out);
}
}
use of org.junit.runners.model.InitializationError in project vert.x by eclipse.
the class AsyncTestBaseTest method testReportLateFailures.
@Test
public void testReportLateFailures() {
Result result;
try {
result = new JUnitCore().run(new BlockJUnit4ClassRunner(LateFailureReport.class));
} catch (InitializationError initializationError) {
throw new AssertionError(initializationError);
}
assertEquals(1, result.getFailureCount());
assertEquals(IllegalStateException.class, result.getFailures().get(0).getException().getClass());
}
use of org.junit.runners.model.InitializationError in project xtext-eclipse by eclipse.
the class RunnerBuilder method getScenarios.
private static Scenario[] getScenarios(Class<?> klass, boolean completeInput) throws InitializationError {
Scenarios annotation = klass.getAnnotation(Scenarios.class);
if (annotation == null) {
return Scenario.values();
} else if (completeInput) {
throw new InitializationError("Must not use ProcessedBy.processCompleteInput together with the Scenarios annotation");
}
Scenario[] result = annotation.value();
if (result.length == 0) {
throw new InitializationError("Must at least specify one smoke test scenario or omit the Scenarios annotation");
}
return result;
}
use of org.junit.runners.model.InitializationError in project drools-wb by kiegroup.
the class ScenarioRunnerService method run.
public TestScenarioResult run(final String identifier, final Scenario scenario, final KieModule module) {
try {
final HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
final String ksessionName = getKSessionName(scenario.getKSessions());
ksessions.put(ksessionName, loadKSession(module, ksessionName));
final AuditLogger auditLogger = new AuditLogger(ksessions);
final ScenarioRunner4JUnit scenarioRunner = new ScenarioRunner4JUnit(scenario, ksessions, getMaxRuleFirings());
final TestResultMessage testResultMessage = run(identifier, null, scenarioRunner);
return new TestScenarioResult(scenario, auditLogger.getLog(), testResultMessage);
} catch (InitializationError initializationError) {
throw new GenericPortableException(initializationError.getMessage());
}
}
Aggregations