Skip to content
This repository
Browse code

Merge pull request #31 from drewfish/exit-code

added --exitCode=true to return non-zero if any tests fail
  • Loading branch information...
commit 7bcc3cdec0fe6f27d67763675989947febdc5c4b 2 parents 46cf109 + 7d57304
proverma proverma authored
1  config/config.js
@@ -26,6 +26,7 @@ config.descriptorName = "test_descriptor.json";
26 26 config.minPort = 10000;
27 27 config.maxPort = 11000;
28 28 config.coverage = false;
  29 +config.exitCode = false;
29 30
30 31
31 32 module.exports = config;
4 index.js
@@ -45,7 +45,8 @@ var knownOpts = {
45 45 "context": [String, null],
46 46 "dimensions": [String, null],
47 47 "capabilities": [String, null],
48   - "seleniumHost": [String, null]
  48 + "seleniumHost": [String, null],
  49 + "exitCode": Boolean
49 50 },
50 51 shortHands = {},
51 52 //TODO : Investigate and implement shorthands
@@ -100,6 +101,7 @@ function showHelp() {
100 101 " Example Json :" + "\n" +
101 102 " {\"yahoo.com\" : \"1.2.3.4\", \"sports.yahoo.com\" : \"3.4.5.6\"}" + "\n" +
102 103 " --useProxyForAll : (optional) true/false. ( default : true ) decides if all selenium browser should by default use proxy server or not" +
  104 + " --exitCode : (optional) true/false. Causes the exit code to be non-zero if any tests fail (default: false)" + "\n" +
103 105 " \n\n");
104 106
105 107 console.log("\nEXAMPLES :" + "\n" +
23 lib/session/sessionfactory.js
@@ -392,7 +392,12 @@ SessionFactory.prototype.tearDown = function (testQueue, wdSessions) {
392 392 reportFile,
393 393 covFile,
394 394 obj,
395   - i;
  395 + i,
  396 + failed,
  397 + s,
  398 + session,
  399 + r,
  400 + reports;
396 401
397 402 //adding this for unit testing
398 403 this.testQueue = testQueue;
@@ -459,7 +464,21 @@ SessionFactory.prototype.tearDown = function (testQueue, wdSessions) {
459 464 }
460 465
461 466 if (global.workingDirectory) {
462   - process.exit(0);
  467 + failed = false;
  468 + if (this.args.exitCode) {
  469 + for (s in reportObj.arrTestSessions) {
  470 + if (reportObj.arrTestSessions.hasOwnProperty(s)) {
  471 + session = reportObj.arrTestSessions[s];
  472 + reports = session.driver.reports.report.results || [];
  473 + for (r = 0; r < reports.length; r += 1) {
  474 + if (reports[r].failed) {
  475 + failed = true;
  476 + }
  477 + }
  478 + }
  479 + }
  480 + }
  481 + process.exit(failed ? 1: 0);
463 482 }
464 483 }
465 484 };

0 comments on commit 7bcc3cd

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