/** Run Phantom test runner on a set of files */ @Override public void execute() throws BuildException { checkAttributes(); DirectoryScanner dirScanner = getDirectoryScanner(dir); String[] includedFiles = dirScanner.getIncludedFiles(); String[] absoluteFiles = new String[includedFiles.length]; for (int i = 0; i < includedFiles.length; i++) { absoluteFiles[i] = dir.getAbsolutePath() + "/" + includedFiles[i]; } // summarize results try { PhantomTestRunner testRunner = new PhantomTestRunner(getPhantom()); testRunner.setLogger(this); log("Running JS Tests..."); log("-------------------------------------------------------------------------------"); JsTestResults results = testRunner.runTests(absoluteFiles); log("-------------------------------------------------------------------------------"); log("Running JS Tests Completed"); int passCount = results.getPassCount(); int failCount = results.getFailCount(); int errorCount = results.getErrorCount(); log(passCount + " passed. " + failCount + " failed. " + errorCount + " errors"); reportResults(results); if (failCount > 0 || errorCount > 0) { String message = getFailureMessage(failCount, errorCount); if (fail) { throw new BuildException(message); } else { log(message); } } else { log(getSuccessMessage(passCount)); } } catch (IOException e) { throw new BuildException("An IO Exception caused while running JS Unit tests", e); } }
protected static String getSuccessMessage(int passCount) { return PhantomTestRunner.getSuccessMessage(passCount); }
protected static String getFailureMessage(int failCount, int errorCount) { return PhantomTestRunner.getFailureMessage(failCount, errorCount); }