/** * Convert the collected {@link Throwable Throwables} into a {@link TestExecutionResult}. * * @return {@linkplain TestExecutionResult#aborted aborted} if the collected * {@code Throwable} <em>aborted</em> execution; * {@linkplain TestExecutionResult#failed failed} if it <em>failed</em> * execution; and {@linkplain TestExecutionResult#successful successful} * otherwise */ TestExecutionResult toTestExecutionResult() { if (isEmpty()) { return successful(); } if (hasAbortedExecution(throwable)) { return aborted(throwable); } return failed(throwable); }
/** * Execute the supplied {@link Executable} and return a * {@link TestExecutionResult} based on the outcome. * * <p>If the {@code Executable} throws a <em>blacklisted</em> exception * — for example, an {@link OutOfMemoryError} — this method will * rethrow it. * * @param executable the test to be executed * @return {@linkplain TestExecutionResult#aborted aborted} if the * {@code Executable} throws a {@link TestAbortedException}; * {@linkplain TestExecutionResult#failed failed} if any other * {@link Throwable} is thrown; and {@linkplain TestExecutionResult#successful * successful} otherwise */ public TestExecutionResult executeSafely(Executable executable) { try { executable.execute(); return successful(); } catch (TestAbortedException e) { return aborted(e); } catch (Throwable t) { rethrowIfBlacklisted(t); return failed(t); } }