private String alternativeMethodName(TestOutcome testOutcome) {
   Optional<String> qualifier = testOutcome.getQualifier();
   if (qualifier.isPresent()) {
     return testOutcome.getTitle(false) + testOutcome.getQualifier().get();
   } else {
     return testOutcome.getTitle();
   }
 }
  /** Case for easyb integration, where we use a Story class directly. */
  @Test
  public void a_test_outcome_title_should_be_the_method_name_if_no_test_class_is_defined() {
    net.thucydides.core.model.Story story = net.thucydides.core.model.Story.from(AUserStory.class);

    TestOutcome outcome = TestOutcome.forTestInStory("Some scenario", story);

    assertThat(outcome.getTitle(), is("Some scenario"));
  }
  @Test
  public void the_test_runner_records_the_steps_as_they_are_executed() throws InitializationError {

    ThucydidesRunner runner = new ThucydidesRunner(LongSamplePassingScenarioUsingFirefox.class);
    runner.run(new RunNotifier());

    List<TestOutcome> executedSteps = runner.getTestOutcomes();
    assertThat(executedSteps.size(), is(1));
    TestOutcome testOutcome1 = executedSteps.get(0);

    assertThat(testOutcome1.getTitle(), is("Happy day scenario"));
    assertThat(testOutcome1.getMethodName(), is("happy_day_scenario"));
    assertThat(testOutcome1.getTestSteps().size(), is(3));
    assertThat(testOutcome1.getScreenshots().size(), is(not(0)));
  }
  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);
  }
  /** Generate an XML report for a given test run. */
  public File generateReportFor(final TestOutcome testOutcome, final TestOutcomes allTestOutcomes)
      throws IOException {
    TestOutcome storedTestOutcome = testOutcome.withQualifier(qualifier);
    Preconditions.checkNotNull(outputDirectory);
    XStream xstream = new XStream();
    xstream.alias("acceptance-test-run", TestOutcome.class);
    xstream.registerConverter(usingXmlConverter());

    String reportFilename = reportFor(storedTestOutcome);

    File report = new File(getOutputDirectory(), reportFilename);

    LOGGER.debug(
        "Generating XML report for {} to file {}",
        testOutcome.getTitle(),
        report.getAbsolutePath());

    try (OutputStream outputStream = new FileOutputStream(report);
        OutputStreamWriter writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {
      xstream.toXML(storedTestOutcome, writer);
      LOGGER.debug("XML report generated ({} bytes) {}", report.getAbsolutePath(), report.length());
    }
    return report;
  }
 private void addTitleLevelIssuesTo(List<String> issues) {
   List<String> titleIssues = Formatter.issuesIn(testOutcome.getTitle());
   if (!titleIssues.isEmpty()) {
     issues.addAll(titleIssues);
   }
 }
 @Test
 public void a_test_outcome_title_can_be_overriden_manually_even_with_an_annotation() {
   TestOutcome outcome = TestOutcome.forTest("should_do_this", SomeAnnotatedTestScenario.class);
   outcome.setTitle("My custom title");
   assertThat(outcome.getTitle(), is("My custom title"));
 }
  @Test
  public void a_test_outcome_title_can_be_overriden_using_the_Title_annotation() {
    TestOutcome outcome = TestOutcome.forTest("should_do_this", SomeAnnotatedTestScenario.class);

    assertThat(outcome.getTitle(), is("Really should do this!"));
  }
  /** Case for JUnit integration, where a test case is present. */
  @Test
  public void a_test_outcome_title_should_be_based_on_the_tested_method_name_if_defined() {
    TestOutcome outcome = TestOutcome.forTest("should_do_this", SomeTestScenario.class);

    assertThat(outcome.getTitle(), is("Should do this"));
  }