@Test
  public void should_count_the_total_number_of_steps_with_each_outcome_in_acceptance_test_run()
      throws Exception {
    TestOutcome testOutcome = TestOutcome.forTest("a_simple_test_case", SomeTestScenario.class);
    String expectedReport =
        "<acceptance-test-run title='A simple test case' name='a_simple_test_case' steps='9' successful='2' failures='3' skipped='1' ignored='2' pending='1' result='FAILURE'>\n"
            + "  <user-story id='net.thucydides.core.reports.integration.WhenGeneratingAnXMLReport.AUserStory' name='A user story' />\n"
            + "  <test-step result='SUCCESS'>\n"
            + "    <description>step 1</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='IGNORED'>\n"
            + "    <description>step 2</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='IGNORED'>\n"
            + "    <description>step 3</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='SUCCESS'>\n"
            + "    <description>step 4</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='FAILURE'>\n"
            + "    <description>step 5</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='FAILURE'>\n"
            + "    <description>step 6</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='FAILURE'>\n"
            + "    <description>step 7</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='SKIPPED'>\n"
            + "    <description>step 8</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='PENDING'>\n"
            + "    <description>step 9</description>\n"
            + "  </test-step>\n"
            + "</acceptance-test-run>";

    testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 1"));
    testOutcome.recordStep(TestStepFactory.ignoredTestStepCalled("step 2"));
    testOutcome.recordStep(TestStepFactory.ignoredTestStepCalled("step 3"));
    testOutcome.recordStep(TestStepFactory.successfulTestStepCalled("step 4"));
    testOutcome.recordStep(TestStepFactory.failingTestStepCalled("step 5"));
    testOutcome.recordStep(TestStepFactory.failingTestStepCalled("step 6"));
    testOutcome.recordStep(TestStepFactory.failingTestStepCalled("step 7"));
    testOutcome.recordStep(TestStepFactory.skippedTestStepCalled("step 8"));
    testOutcome.recordStep(TestStepFactory.pendingTestStepCalled("step 9"));

    File xmlReport = reporter.generateReportFor(testOutcome);
    String generatedReportText = getStringFrom(xmlReport);

    assertThat(generatedReportText, isSimilarTo(expectedReport));
  }
  @Test
  public void should_include_the_name_of_any_screenshots_where_present() throws Exception {
    TestOutcome testOutcome = TestOutcome.forTest("a_simple_test_case", SomeTestScenario.class);
    String expectedReport =
        "<acceptance-test-run title='A simple test case' name='a_simple_test_case' steps='2' successful='1' failures='1' skipped='0' ignored='0' pending='0' result='FAILURE'>\n"
            + "  <user-story id='net.thucydides.core.reports.integration.WhenGeneratingAnXMLReport.AUserStory' name='A user story' />\n"
            + "  <test-step result='SUCCESS'>\n"
            + "    <screenshots>\n"
            + "      <screenshot image='step_1.png' source='step_1.html'/>\n"
            + "    </screenshots>\n"
            + "    <description>step 1</description>\n"
            + "  </test-step>\n"
            + "  <test-step result='FAILURE'>\n"
            + "    <description>step 2</description>\n"
            + "  </test-step>\n"
            + "</acceptance-test-run>";

    File screenshot = temporaryDirectory.newFile("step_1.png");
    File source = temporaryDirectory.newFile("step_1.html");

    TestStep step1 = TestStepFactory.successfulTestStepCalled("step 1");
    step1.addScreenshot(new ScreenshotAndHtmlSource(screenshot, source));
    testOutcome.recordStep(step1);
    testOutcome.recordStep(TestStepFactory.failingTestStepCalled("step 2"));

    File xmlReport = reporter.generateReportFor(testOutcome);
    String generatedReportText = getStringFrom(xmlReport);

    assertThat(generatedReportText, isSimilarTo(expectedReport));
  }
  @Test
  public void should_include_error_message_for_failing_test() throws Exception {
    TestOutcome testOutcome = TestOutcome.forTest("a_simple_test_case", SomeTestScenario.class);

    TestStep step = TestStepFactory.failingTestStepCalled("step 1");
    step.failedWith(new IllegalArgumentException("Oh nose!"));

    testOutcome.recordStep(step);

    File xmlReport = reporter.generateReportFor(testOutcome);
    String generatedReportText = getStringFrom(xmlReport);

    assertThat(generatedReportText, containsString("<error>Oh nose!</error>"));
  }