Skip to content
Browse files

Merge pull request #31 from drewfish/exit-code

added --exitCode=true to return non-zero if any tests fail
  • Loading branch information...
2 parents 46cf109 + 7d57304 commit 7bcc3cdec0fe6f27d67763675989947febdc5c4b @proverma proverma committed Dec 11, 2012
Showing with 25 additions and 3 deletions.
  1. +1 −0 config/config.js
  2. +3 −1 index.js
  3. +21 −2 lib/session/sessionfactory.js
View
1 config/config.js
@@ -26,6 +26,7 @@ config.descriptorName = "test_descriptor.json";
config.minPort = 10000;
config.maxPort = 11000;
config.coverage = false;
+config.exitCode = false;
module.exports = config;
View
4 index.js
@@ -45,7 +45,8 @@ var knownOpts = {
"context": [String, null],
"dimensions": [String, null],
"capabilities": [String, null],
- "seleniumHost": [String, null]
+ "seleniumHost": [String, null],
+ "exitCode": Boolean
},
shortHands = {},
//TODO : Investigate and implement shorthands
@@ -100,6 +101,7 @@ function showHelp() {
" Example Json :" + "\n" +
" {\"yahoo.com\" : \"1.2.3.4\", \"sports.yahoo.com\" : \"3.4.5.6\"}" + "\n" +
" --useProxyForAll : (optional) true/false. ( default : true ) decides if all selenium browser should by default use proxy server or not" +
+ " --exitCode : (optional) true/false. Causes the exit code to be non-zero if any tests fail (default: false)" + "\n" +
" \n\n");
console.log("\nEXAMPLES :" + "\n" +
View
23 lib/session/sessionfactory.js
@@ -392,7 +392,12 @@ SessionFactory.prototype.tearDown = function (testQueue, wdSessions) {
reportFile,
covFile,
obj,
- i;
+ i,
+ failed,
+ s,
+ session,
+ r,
+ reports;
//adding this for unit testing
this.testQueue = testQueue;
@@ -459,7 +464,21 @@ SessionFactory.prototype.tearDown = function (testQueue, wdSessions) {
}
if (global.workingDirectory) {
- process.exit(0);
+ failed = false;
+ if (this.args.exitCode) {
+ for (s in reportObj.arrTestSessions) {
+ if (reportObj.arrTestSessions.hasOwnProperty(s)) {
+ session = reportObj.arrTestSessions[s];
+ reports = session.driver.reports.report.results || [];
+ for (r = 0; r < reports.length; r += 1) {
+ if (reports[r].failed) {
+ failed = true;
+ }
+ }
+ }
+ }
+ }
+ process.exit(failed ? 1: 0);
}
}
};

0 comments on commit 7bcc3cd

Please sign in to comment.
Something went wrong with that request. Please try again.