private Converter<TestCase, TestOutcome> toTestOutcomes() {
return new Converter<TestCase, TestOutcome>() {
@Override
public TestOutcome convert(TestCase from) {
TestOutcome outcome = TestOutcome.forTestInStory(from.getName(), Story.called(from.getClassname()));
outcome.setTitle(NameConverter.humanize(from.getName()));
outcome.setDuration(timeAsLong(from.getTime()));
if (from.getError().isPresent()) {
TestException failure = from.getError().get();
outcome.determineTestFailureCause(failure.asException());
} else if (from.getFailure().isPresent()) {
TestException failure = from.getFailure().get();
outcome.determineTestFailureCause(failure.asAssertionFailure());
} else if (from.getSkipped().isPresent()) {
//although it is logged by junit as 'skipped', Thucydides
//makes a distinction between skipped and ignored.
//outcome.setAnnotatedResult(TestResult.IGNORED);
//setting the outcome to PENDING for now as the reports don't yet handle the
//ignored test cases
outcome.setAnnotatedResult(TestResult.PENDING);
} else {
outcome.setAnnotatedResult(TestResult.SUCCESS);
}
return outcome;
}
};
}