Skip to content

Commit

Permalink
fixed an issue with printing the global test report
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Jan 13, 2014
1 parent 95843aa commit 7a5eba2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 2 additions & 4 deletions lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ AsyncTree.prototype.append = function(nodeName, command, context, args) {
parent : this.currentNode
};
this.currentNode.children.push(node);
//Logger.log(' -- queue append', node.name, 'to', this.currentNode.name, this.currentNode.started && 'started' || 'not started', this.currentNode.done && 'done' || 'not done');

if (this.currentNode.started && !this.currentNode.done) {
this.traverse();
}
Expand All @@ -37,7 +37,6 @@ AsyncTree.prototype.append = function(nodeName, command, context, args) {
AsyncTree.prototype.walkDown = function walkDown(context) {
var self = this;
var node = this.getNextChild(context);
//Logger.log(' -- queue walkDown', context.name, ' has subnode:', node.name || false);

if (node) {
this.currentNode = node;
Expand All @@ -63,7 +62,6 @@ AsyncTree.prototype.walkDown = function walkDown(context) {
if (this.currentNode.name == '__root__') {
this.done();
} else {
//Logger.log(' -- queue walkUp', context.name, ' has subnodes:', context.children.length || false);
this.walkUp(context);
}
}
Expand All @@ -86,7 +84,6 @@ AsyncTree.prototype.getNextChild = function(context) {

AsyncTree.prototype.run = function(node) {
node.started = true;
//Logger.log(Logger.colors.light_gray(' - Running command ' + Logger.colors.light_green(node.name)));
try {
return node.command.apply(node.context, node.args);
} catch (err) {
Expand Down Expand Up @@ -135,6 +132,7 @@ exports.run = function run(callback) {
if (queue.rootNode.started) {
return queue;
}

if (callback) {
queue.once('queue:finished', function() {
callback(null);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nightwatch",
"description": "A node.js bindings implementation for selenium 2.0/webdriver",
"version": "0.1.2",
"version": "0.1.3",
"author": {
"name": "Andrei Rusu",
"email": "andrei.rusu@beatfactor.net"
Expand Down
13 changes: 8 additions & 5 deletions runner/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ exports.run = function runner(files, opts, aditional_opts, finishCallback) {
runTestModule(err, fullpaths);
}, 0);
} else {
if (testresults.tests != globalresults.tests) {
if (testresults.tests != globalresults.tests || testresults.steps.length > 1) {
printResults(globalresults);
}


var output = aditional_opts.output_folder;
if (output === false) {
finishCallback();
Expand Down Expand Up @@ -156,7 +155,7 @@ exports.stopSelenium = function(callback) {

function printResults(testresults) {
if (testresults.passed > 0 && testresults.errors == 0 && testresults.failed == 0) {
console.log(Logger.colors.green("\nOK.", Logger.colors.background.black), testresults.passed + ' assertions passed.');
console.log(Logger.colors.green("\nOK. " + testresults.passed, Logger.colors.background.black), 'total assertions passed.');
} else {
var skipped = '';
if (testresults.skipped) {
Expand All @@ -176,18 +175,20 @@ function runModule(module, opts, moduleName, callback) {
failed:0,
errors:0,
skipped:0,
tests:0
tests:0,
steps:keys.slice(0)
};

var setUp, tearDown;
module.client = client;

if (keys.indexOf('setUp') > -1) {
setUp = function(clientFn) {
module.setUp();
module.setUp(module.client);
clientFn();
};
keys.splice(keys.indexOf('setUp'), 1);
testresults.steps.splice(testresults.steps.indexOf('setUp'), 1);
} else {
setUp = function(callback) {callback();}
}
Expand All @@ -198,6 +199,8 @@ function runModule(module, opts, moduleName, callback) {
clientFn();
};
keys.splice(keys.indexOf('tearDown'), 1);
testresults.steps.splice(testresults.steps.indexOf('tearDown'), 1);

} else {
tearDown = function(callback) {callback();}
}
Expand Down

0 comments on commit 7a5eba2

Please sign in to comment.