@Test
  public void should_load_test_step_details_with_no_screenshot_source_from_xml_file()
      throws Exception {
    String storedReportXML =
        "<acceptance-test-run title='Should do this' name='should_do_this' steps='1' successful='1' failures='0' skipped='0' ignored='0' pending='0' result='SUCCESS'>\n"
            + "  <user-story id='net.thucydides.core.reports.integration.WhenGeneratingAnXMLReport.AUserStory' name='A user story' />\n"
            + "  <test-step result='SUCCESS'>\n"
            + "    <screenshots>"
            + "      <screenshot image='step_1.png'/>"
            + "    </screenshots>"
            + "    <description>step 1</description>\n"
            + "  </test-step>\n"
            + "</acceptance-test-run>";

    File report = temporaryDirectory.newFile("saved-report.xml");
    FileUtils.writeStringToFile(report, storedReportXML);

    Optional<TestOutcome> testOutcome = outcomeReporter.loadReportFrom(report);

    TestStep testStep = (TestStep) testOutcome.get().getTestSteps().get(0);
    assertThat(testOutcome.get().getTestSteps().size(), is(1));
    assertThat(testStep.getResult(), is(TestResult.SUCCESS));
    assertThat(testStep.getDescription(), is("step 1"));
    assertThat(testStep.getScreenshots().get(0).getScreenshotFile().getName(), is("step_1.png"));
    assertThat(testStep.getScreenshots().get(0).getSourcecode().isPresent(), is(false));
  }
  private void recordTestOutcomeAsSteps(TestOutcome testOutcome, TestOutcome scenarioOutcome) {
    TestStep nestedStep =
        TestStep.forStepCalled(testOutcome.getTitle()).withResult(testOutcome.getResult());
    List<TestStep> testSteps = testOutcome.getTestSteps();

    if (testOutcome.getTestFailureCause() != null) {
      nestedStep.failedWith(testOutcome.getTestFailureCause().toException());
    }

    if (!testSteps.isEmpty()) {
      for (TestStep nextStep : testSteps) {
        nextStep.setDescription(
            normalizeTestStepDescription(
                nextStep.getDescription(), scenarioOutcome.getTestSteps().size() + 1));
        nestedStep.addChildStep(nextStep);
      }
    }
    scenarioOutcome.recordStep(nestedStep);
  }
  private void recordTestOutcomeAsSteps(TestOutcome testOutcome, TestOutcome scenarioOutcome) {
    final String name = alternativeMethodName(testOutcome);
    TestStep nestedStep = TestStep.forStepCalled(name).withResult(testOutcome.getResult());
    List<TestStep> testSteps = testOutcome.getTestSteps();

    if (testOutcome.getTestFailureCause() != null) {
      nestedStep.failedWith(testOutcome.getTestFailureCause().toException());
    }

    if (!testSteps.isEmpty()) {
      for (TestStep nextStep : testSteps) {
        nextStep.setDescription(
            normalizeTestStepDescription(
                nextStep.getDescription(), scenarioOutcome.getTestSteps().size() + 1));
        nestedStep.addChildStep(nextStep);
        nestedStep.setDuration(nextStep.getDuration() + nestedStep.getDuration());
      }
    }

    if (nestedStep.getDuration() == 0) {
      nestedStep.setDuration(testOutcome.getDuration());
    }
    scenarioOutcome.recordStep(nestedStep);
  }