@Override
  public void doCommand(String... args)
      throws CommandArgumentsException, CommandOperationException {
    validateArguments(args);
    File testRoot = getTestRoot(args);
    WebDriverProvider.setBaseUrl(getUrl(args));

    TestCompiler testCompiler = new TestCompiler();

    out.println("Running integration tests in " + testRoot.getPath());
    out.println("Running integration tests using root URL: " + WebDriverProvider.getBaseUrl(""));
    out.println("");

    File classesRoot = null;
    try {
      classesRoot = testCompiler.getClassesRoot(testRoot);
    } catch (IOException ex) {
      throw new CommandOperationException("Error creating directory for compiled tests.", ex);
    }
    if (classesRoot.exists()) {
      FileUtils.deleteQuietly(classesRoot);
    }

    List<File> testContainerDirs =
        new IntegrationTestFinder().findTestContainerDirs(testRoot, ignoreWorkbenches(args));
    if (testContainerDirs.size() < 1) {
      throw new CommandOperationException("No tests found.");
    }
    out.println("Found tests in " + testContainerDirs.size() + " location(s).");

    List<File> classDirs = testCompiler.compileTestDirs(testContainerDirs);

    List<Class<?>> testClasses = testCompiler.loadClasses(classDirs);

    Result testResult = null;
    try {
      File runnerConf = TestRunnerConfLocator.getTestRunnerConf();
      testResult = new IntegrationTestRunner().runTests(runnerConf, testClasses);
    } catch (Exception ex) {
      throw new CommandOperationException(ex);
    }

    printTestReport(testResult);
    if (testResult.getFailures().size() > 0) {
      throw new CommandOperationException("There were failing tests.");
    }
  }
 private void printTestReport(Result testResult) {
   out.println("");
   out.println("== Test report ==");
   out.println("Tests run: " + testResult.getRunCount());
   out.println("Failed tests: " + testResult.getFailureCount());
   out.println("Ignored tests: " + testResult.getIgnoreCount());
   out.println("");
   BRJSAccessor.root.getConsoleWriter().flush();
   if (testResult.getFailures().size() > 0) {
     out.println("- Failures -");
     for (Failure fail : testResult.getFailures()) {
       out.println("");
       out.println("--------------------------------");
       out.println(fail.getDescription().toString());
       out.println(fail.getException().toString());
       out.println(fail.getTrace());
       out.println("--------------------------------");
       out.println("");
       out.println("");
     }
   }
   System.out.flush();
 }