@Test public void when_a_step_fails_the_error_message_can_be_recorded() throws IOException { TestStep step = new TestStep("a narrative description"); step.setResult(TestResult.FAILURE); step.failedWith(new Exception("Oh nose!")); assertThat(step.getErrorMessage(), containsString("Oh nose!")); }
@Test public void when_a_step_fails_with_a_cause_the_original_message_is_used() throws IOException { TestStep step = new TestStep("a narrative description"); step.setResult(TestResult.FAILURE); Throwable e = new IllegalStateException("Original error"); step.failedWith(new Exception("Oh nose", e)); assertThat(step.getErrorMessage(), containsString("Original error")); }