@Test
  public void should_record_nested_pending_steps() {
    SimpleTestScenarioSteps steps = factory.getStepLibraryFor(SimpleTestScenarioSteps.class);

    StepEventBus.getEventBus().testStarted("a_test", SampleTestScenario.class);
    steps.step1();
    steps.step9();
    StepEventBus.getEventBus().testFinished(testOutcome);

    String expectedSteps =
        "TEST a_test\n"
            + "-step1\n"
            + "---> STEP DONE\n"
            + "-step9\n"
            + "--step1\n"
            + "----> STEP DONE\n"
            + "--pendingStep\n"
            + "----> STEP PENDING\n"
            + "--step4\n"
            + "---step5\n"
            + "-----> STEP DONE\n"
            + "---step6\n"
            + "-----> STEP DONE\n"
            + "----> STEP DONE\n"
            + "---> STEP DONE\n"
            + "TEST DONE\n";

    System.out.println(consoleStepListener.toString());
    assertThat(consoleStepListener.toString(), is(expectedSteps));
  }
  @Test
  public void when_an_entier_test_is_ignored_the_test_is_marked_as_ignored() {
    StepEventBus.getEventBus().testStarted("a_test", SampleTestScenario.class);
    StepEventBus.getEventBus().testIgnored();
    StepEventBus.getEventBus().testFinished(testOutcome);

    String expectedSteps = "TEST a_test\n" + "--> TEST IGNORED\n" + "TEST DONE\n";
    assertThat(consoleStepListener.toString(), is(expectedSteps));
  }
  @Test
  public void a_step_can_be_marked_pending() {
    StepEventBus.getEventBus().testStarted("a_test", SampleTestScenario.class);
    StepEventBus.getEventBus().stepStarted(ExecutedStepDescription.withTitle("a step"));
    StepEventBus.getEventBus().stepPending();
    StepEventBus.getEventBus().testFinished(testOutcome);

    String expectedSteps = "TEST a_test\n" + "-a step\n" + "---> STEP PENDING\n" + "TEST DONE\n";
    assertThat(consoleStepListener.toString(), is(expectedSteps));
  }
  @Test
  public void should_clear_all_listeners_when_requested() {
    StepEventBus.getEventBus().dropAllListeners();

    StepEventBus.getEventBus().testStarted("a_test", SampleTestScenario.class);
    StepEventBus.getEventBus().stepStarted(ExecutedStepDescription.withTitle("a step"));
    StepEventBus.getEventBus().stepPending();
    StepEventBus.getEventBus().testFinished(testOutcome);

    assertThat(consoleStepListener.toString(), is(""));
  }
  @Test
  public void should_record_when_a_test_starts_and_finishes() {
    SimpleTestScenarioSteps steps = factory.getStepLibraryFor(SimpleTestScenarioSteps.class);

    StepEventBus.getEventBus().testStarted("a_test", SampleTestScenario.class);
    steps.step1();
    StepEventBus.getEventBus().testFinished(testOutcome);

    String expectedSteps = "TEST a_test\n" + "-step1\n" + "---> STEP DONE\n" + "TEST DONE\n";
    assertThat(consoleStepListener.toString(), is(expectedSteps));
  }
  @Test
  public void a_step_can_return_a_step_object_if_a_failure_occurs() {
    SimpleTestScenarioSteps steps = factory.getStepLibraryFor(SimpleTestScenarioSteps.class);

    StepEventBus.getEventBus().testStarted("a_test", SampleTestScenario.class);
    steps.stepThatFailsAndReturnsAStep().stepThatReturnsAStep();
    StepEventBus.getEventBus().testFinished(testOutcome);

    String expectedSteps =
        "TEST a_test\n"
            + "-stepThatFailsAndReturnsAStep\n"
            + "---> STEP FAILED\n"
            + "-stepThatReturnsAStep\n"
            + "---> STEP IGNORED\n"
            + "TEST DONE\n";
    assertThat(consoleStepListener.toString(), is(expectedSteps));
  }
  @Test
  public void should_record_groups_as_nested_test_steps() {
    SimpleTestScenarioSteps steps = factory.getStepLibraryFor(SimpleTestScenarioSteps.class);

    StepEventBus.getEventBus().testStarted("a_test", SampleTestScenario.class);
    steps.nested_steps();
    StepEventBus.getEventBus().testFinished(testOutcome);

    String expectedSteps =
        "TEST a_test\n"
            + "-nested_steps\n"
            + "--step1\n"
            + "----> STEP DONE\n"
            + "--nested_steps1\n"
            + "---step1\n"
            + "-----> STEP DONE\n"
            + "---nested_steps2\n"
            + "----step1\n"
            + "------> STEP DONE\n"
            + "----step4\n"
            + "-----step5\n"
            + "-------> STEP DONE\n"
            + "-----step6\n"
            + "-------> STEP DONE\n"
            + "------> STEP DONE\n"
            + "-----> STEP DONE\n"
            + "---step4\n"
            + "----step5\n"
            + "------> STEP DONE\n"
            + "----step6\n"
            + "------> STEP DONE\n"
            + "-----> STEP DONE\n"
            + "----> STEP DONE\n"
            + "--step4\n"
            + "---step5\n"
            + "-----> STEP DONE\n"
            + "---step6\n"
            + "-----> STEP DONE\n"
            + "----> STEP DONE\n"
            + "---> STEP DONE\n"
            + "TEST DONE\n";

    assertThat(consoleStepListener.toString(), is(expectedSteps));
  }
  @Test
  public void when_an_entier_test_is_pending_all_the_contained_steps_are_skipped() {
    SimpleTestScenarioSteps steps = factory.getStepLibraryFor(SimpleTestScenarioSteps.class);

    StepEventBus.getEventBus().testStarted("a_test", SampleTestScenario.class);
    StepEventBus.getEventBus().testPending();
    steps.step1();
    steps.step2();
    steps.step3();
    StepEventBus.getEventBus().testFinished(testOutcome);

    String expectedSteps =
        "TEST a_test\n"
            + "-step1\n"
            + "---> STEP IGNORED\n"
            + "-step2\n"
            + "---> STEP IGNORED\n"
            + "-step3\n"
            + "---> STEP IGNORED\n"
            + "TEST DONE\n";
    assertThat(consoleStepListener.toString(), is(expectedSteps));
  }
  @Test
  public void should_not_use_the_browser() {
    SimpleTestScenarioSteps steps = factory.getStepLibraryFor(SimpleTestScenarioSteps.class);

    StepEventBus.getEventBus().testStarted("a_test", SampleTestScenario.class);
    steps.step1();
    steps.step7();
    StepEventBus.getEventBus().testFinished(testOutcome);

    String expectedSteps =
        "TEST a_test\n"
            + "-step1\n"
            + "---> STEP DONE\n"
            + "-step7\n"
            + "--step1\n"
            + "----> STEP DONE\n"
            + "--failingStep\n"
            + "----> STEP FAILED\n"
            + "--step2\n"
            + "----> STEP IGNORED\n"
            + "---> STEP DONE\n"
            + "TEST DONE\n";
    assertThat(consoleStepListener.toString(), is(expectedSteps));
  }