Search in sources :

Example 6 with SomethingIsWrong

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);
    }
}
Also used : SomethingIsWrong(com.sun.tck.lib.tgf.SomethingIsWrong) BeforeTestGroup(com.sun.tck.lib.BeforeTestGroup)

Example 7 with SomethingIsWrong

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);
    });
}
Also used : SomethingIsWrong(com.sun.tck.lib.tgf.SomethingIsWrong) NotApplicableException(com.sun.tck.lib.NotApplicableException) TestResult(com.oracle.tck.lib.autd2.TestResult)

Aggregations

SomethingIsWrong (com.sun.tck.lib.tgf.SomethingIsWrong)7 NotApplicableException (com.sun.tck.lib.NotApplicableException)3 TestResult (com.oracle.tck.lib.autd2.TestResult)2 Annotation (java.lang.annotation.Annotation)2 AfterTestGroup (com.sun.tck.lib.AfterTestGroup)1 BeforeTestGroup (com.sun.tck.lib.BeforeTestGroup)1 ExpectedExceptions (com.sun.tck.lib.ExpectedExceptions)1 TestFailedException (com.sun.tck.lib.TestFailedException)1 AbstractValue (com.sun.tck.lib.tgf.AbstractValue)1 After (com.sun.tck.lib.tgf.After)1 Values (com.sun.tck.lib.tgf.Values)1