private Optional<Throwable> testFailureFrom(TestCase testCase) {
Throwable testFailure = null;
if (testCase.getFailure().isPresent()) {
testFailure = testCase.getFailure().get().asAssertionFailure();
} else if (testCase.getSkipped().isPresent()) {
testFailure = new PendingStepException(testCase.getSkipped().get().getType());
} else if (testCase.getError().isPresent()) {
testFailure = testCase.getError().get().asException();
}
return Optional.fromNullable(testFailure);
}