use of org.junit.internal.AssumptionViolatedException in project cucumber-jvm by cucumber.
the class RuntimeTest method non_strict_with_failed_junit_assumption_prior_to_junit_412.
@Test
public void non_strict_with_failed_junit_assumption_prior_to_junit_412() {
Runtime runtime = createNonStrictRuntime();
runtime.addError(new AssumptionViolatedException("should be treated like pending"));
assertEquals(0x0, runtime.exitStatus());
}
use of org.junit.internal.AssumptionViolatedException in project asterixdb by apache.
the class ParserTestUtil method runTest.
protected static void runTest(Logger logger, ParserTestExecutor parserTestExecutor, String pathQueries, File queryFile, File expectedFile, File actualFile, List<String> ignore, List<String> only, String separator) throws Exception {
final char sep = separator.charAt(0);
try {
String queryFileShort = queryFile.getPath().substring(pathQueries.length()).replace(sep, '/');
if (!only.isEmpty()) {
boolean toRun = TestHelper.isInPrefixList(only, queryFileShort);
if (!toRun) {
logger.info("SKIP TEST: \"" + queryFile.getPath() + "\" \"only.txt\" not empty and not in \"only.txt\".");
}
Assume.assumeTrue(toRun);
}
boolean skipped = TestHelper.isInPrefixList(ignore, queryFileShort);
if (skipped) {
logger.info("SKIP TEST: \"" + queryFile.getPath() + "\" in \"ignore.txt\".");
}
Assume.assumeTrue(!skipped);
logger.info("RUN TEST: \"" + queryFile.getPath() + "\"");
parserTestExecutor.testSQLPPParser(queryFile, actualFile, expectedFile);
} catch (Exception e) {
if (!(e instanceof AssumptionViolatedException)) {
final String msg = "Test \"" + queryFile.getPath() + "\" FAILED!";
logger.severe(msg);
throw new Exception(msg, e);
} else {
throw e;
}
}
}
use of org.junit.internal.AssumptionViolatedException in project asterixdb by apache.
the class OptimizerTest method test.
@Test
public void test() throws Exception {
try {
String queryFileShort = queryFile.getPath().substring(PATH_QUERIES.length()).replace(SEPARATOR.charAt(0), '/');
if (!only.isEmpty()) {
boolean toRun = TestHelper.isInPrefixList(only, queryFileShort);
if (!toRun) {
LOGGER.info("SKIP TEST: \"" + queryFile.getPath() + "\" \"only.txt\" not empty and not in \"only.txt\".");
}
Assume.assumeTrue(toRun);
}
boolean skipped = TestHelper.isInPrefixList(ignore, queryFileShort);
if (skipped) {
LOGGER.info("SKIP TEST: \"" + queryFile.getPath() + "\" in \"ignore.txt\".");
}
Assume.assumeTrue(!skipped);
LOGGER.info("RUN TEST: \"" + queryFile.getPath() + "\"");
Reader query = new BufferedReader(new InputStreamReader(new FileInputStream(queryFile), "UTF-8"));
// Forces the creation of actualFile.
actualFile.getParentFile().mkdirs();
PrintWriter plan = new PrintWriter(actualFile);
ILangCompilationProvider provider = queryFile.getName().endsWith("aql") ? aqlCompilationProvider : sqlppCompilationProvider;
if (extensionLangCompilationProvider != null) {
provider = extensionLangCompilationProvider;
}
IHyracksClientConnection hcc = integrationUtil.getHyracksClientConnection();
AsterixJavaClient asterix = new AsterixJavaClient((ICcApplicationContext) integrationUtil.cc.getApplicationContext(), hcc, query, plan, provider, statementExecutorFactory, storageComponentProvider);
try {
asterix.compile(true, false, false, true, true, false, false);
} catch (AsterixException e) {
plan.close();
query.close();
throw new Exception("Compile ERROR for " + queryFile + ": " + e.getMessage(), e);
}
plan.close();
query.close();
BufferedReader readerExpected = new BufferedReader(new InputStreamReader(new FileInputStream(expectedFile), "UTF-8"));
BufferedReader readerActual = new BufferedReader(new InputStreamReader(new FileInputStream(actualFile), "UTF-8"));
String lineExpected, lineActual;
int num = 1;
try {
while ((lineExpected = readerExpected.readLine()) != null) {
lineActual = readerActual.readLine();
if (lineActual == null) {
throw new Exception("Result for " + queryFile + " changed at line " + num + ":\n< " + lineExpected + "\n> ");
}
if (!lineExpected.equals(lineActual)) {
throw new Exception("Result for " + queryFile + " changed at line " + num + ":\n< " + lineExpected + "\n> " + lineActual);
}
++num;
}
lineActual = readerActual.readLine();
if (lineActual != null) {
throw new Exception("Result for " + queryFile + " changed at line " + num + ":\n< \n> " + lineActual);
}
LOGGER.info("Test \"" + queryFile.getPath() + "\" PASSED!");
actualFile.delete();
} finally {
readerExpected.close();
readerActual.close();
}
} catch (Exception e) {
if (!(e instanceof AssumptionViolatedException)) {
LOGGER.severe("Test \"" + queryFile.getPath() + "\" FAILED!");
throw new Exception("Test \"" + queryFile.getPath() + "\" FAILED!", e);
} else {
throw e;
}
}
}
use of org.junit.internal.AssumptionViolatedException in project spock by spockframework.
the class JUnitSupervisor method error.
@Override
public int error(ErrorInfo error) {
Throwable exception = error.getException();
if (exception instanceof MultipleFailureException)
return handleMultipleFailures(error);
if (isFailedEqualityComparison(exception))
exception = convertToComparisonFailure(exception);
filter.filter(exception);
Failure failure = new Failure(getCurrentDescription(), exception);
if (exception instanceof AssumptionViolatedException) {
// do notify JUnit listeners unless it's a data-driven iteration that's reported as one feature
if (currentIteration == null || !currentFeature.isParameterized() || currentFeature.isReportIterations()) {
notifier.fireTestAssumptionFailed(failure);
}
} else {
masterListener.error(error);
notifier.fireTestFailure(failure);
}
errorSinceLastReset = true;
return statusFor(error);
}
use of org.junit.internal.AssumptionViolatedException 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();
}
}
Aggregations