use of com.sun.tck.lib.tgf.SomethingIsWrong in project jtharness by openjdk.
the class BeforeTestGroupActions method process.
/**
* {@inheritDoc}
*/
@Override
public void process(TestGroupContext.TestGroupLifePhase lifePhase, TestGroupContext context) throws Throwable {
BeforeTestGroup before = (BeforeTestGroup) getTheOnlyTestGroupAnnotationInterestedIn(context);
String methodName = before.value();
try {
searchAndInvoke(methodName, context.getTestGroupInstance().getClass(), context.getTestGroupInstance(), context.getLog());
} catch (SomethingIsWrong e) {
final String message = e.getMessage();
context.printlnToLog(message);
final String failedTryingToInvoke = MessageFormat.format("Failed trying to invoke @BeforeTestGroup method \"{0}\"", methodName);
throw new RuntimeException(failedTryingToInvoke);
}
}
use of com.sun.tck.lib.tgf.SomethingIsWrong in project jtharness by openjdk.
the class RunningTestCases method process.
/**
* {@inheritDoc}
*/
@Override
public void process(TestGroupContext.TestGroupLifePhase lifePhase, TestGroupContext testGroupContext) {
Collection<TestCaseContext> testCases = testGroupContext.getTestCaseContexts();
// todo with streams here we may go parallel if needed in future
testCases.forEach(context -> {
TestResult result;
try {
TestDataCollector.checkIfTestCaseShouldBeExecuted(context.getTestCaseMethod(), context.getTestGroupInstance(), context.getTestGroupInstance().getClass(), context.getLog());
result = runTestCaseAsNeeded(context);
} catch (SomethingIsWrong e) {
// something might be wrong with runtime test skipping for example - @ExecuteIf/Not
context.printlnToLog(e.getMessage());
result = TestResult.failure(e.getMessage());
} catch (NotApplicableException e) {
String message = e.getMessage();
result = new InapplicableTestResult("Not applicable." + (message != null ? " Reason: " + message : ""));
}
// todo improve this
if (result instanceof InapplicableTestResult) {
testGroupContext.recordNotApplicable();
}
testGroupContext.addExecutionResult(context.getTestCaseName(), result);
});
}
Aggregations