@Test
  public void driver_can_be_overridden_using_the_driver_property_in_the_Managed_annotation()
      throws InitializationError {
    environmentVariables.setProperty("webdriver.driver", "opera");

    SerenityRunner runner = getTestRunnerUsing(SuccessfulSingleTestScenarioWithABrowser.class);

    runner.run(new RunNotifier());
  }
  @Test
  public void a_batch_runner_can_be_overridden_using_system_property() throws InitializationError {

    //
    // environmentVariables.setProperty(ThucydidesSystemProperty.THUCYDIDES_BATCH_STRATEGY.getPropertyName(), BatchStrategy.DIVIDE_BY_TEST_COUNT.name());
    environmentVariables.setProperty("thucydides.batch.strategy", "DIVIDE_BY_TEST_COUNT");

    SerenityRunner runner = getTestRunnerUsing(SuccessfulSingleTestScenario.class);

    assertThat(runner.getBatchManager(), instanceOf(TestCountBasedBatchManager.class));
  }
  @Test
  public void the_default_output_directory_should_follow_the_maven_convention()
      throws InitializationError {

    SerenityRunner runner = getTestRunnerUsing(SuccessfulSingleTestScenario.class);

    File outputDirectory = runner.getOutputDirectory();

    assertThat(
        outputDirectory.getPath(),
        is("target" + FILE_SEPARATOR + "site" + FILE_SEPARATOR + "serenity"));
  }
  @Test
  public void lynx_is_not_a_supported_driver() throws InitializationError {
    try {
      environmentVariables.setProperty("webdriver.driver", "lynx");

      SerenityRunner runner = getTestRunnerUsing(SuccessfulSingleTestScenario.class);

      runner.run(new RunNotifier());

      fail("Should have thrown UnsupportedDriverException");
    } catch (UnsupportedDriverException e) {
      assertThat(e.getMessage(), containsString("Unsupported browser type: lynx"));
    }
  }
  @Test
  public void should_not_allow_an_incorrectly_specified_driver() throws InitializationError {
    try {
      environmentVariables.setProperty("webdriver.driver", "firefox");

      SerenityRunner runner =
          getTestRunnerUsing(SuccessfulSingleTestScenarioWithWrongBrowser.class);

      runner.run(new RunNotifier());

      fail("Should have thrown UnsupportedDriverException");
    } catch (UnsupportedDriverException e) {
      assertThat(e.getMessage(), containsString("Unsupported browser type: doesnotexist"));
    }
  }
  @Test
  public void
      the_output_directory_can_be_defined_by_a_system_property_using_any_standard_separators()
          throws InitializationError {

    SerenityRunner runner = getTestRunnerUsing(SuccessfulSingleTestScenario.class);

    environmentVariables.setProperty("thucydides.outputDirectory", "target/reports/thucydides");

    File outputDirectory = runner.getOutputDirectory();

    assertThat(
        outputDirectory.getPath(),
        is("target" + FILE_SEPARATOR + "reports" + FILE_SEPARATOR + "thucydides"));
  }
  @Test
  public void a_batch_runner_is_set_by_default() throws InitializationError {
    SerenityRunner runner = getTestRunnerUsing(SuccessfulSingleTestScenario.class);

    assertThat(runner.getBatchManager(), instanceOf(SystemVariableBasedBatchManager.class));
  }