Permalink
Browse files

new version, messages about failing tests now sent to console.error

  • Loading branch information...
1 parent 1238707 commit 50622d52c3e70333d88f6683bfed16eababae4e0 @victorjonsson committed Feb 7, 2013
Showing with 27 additions and 13 deletions.
  1. +5 −1 CHANGELOG.md
  2. +21 −11 dokimon
  3. +1 −1 package.json
View
@@ -20,4 +20,8 @@
## v 0.0.18
- Extension of test files changed from .dokimon to .djs
- - minor bug fixes
+ - minor bug fixes
+
+## v 0.0.19
+ - Messages about failing tests is now sent to console.error
+ - Added some coloring of messages
View
32 dokimon
@@ -1,6 +1,11 @@
var filesystem = require('fs'),
util = require('util'),
- querystring = require('querystring');
+ querystring = require('querystring'),
+ colors = {
+ red : '\033[31m',
+ green : '\033[32m',
+ reset : '\033[0m'
+ };
/**
@@ -58,12 +63,17 @@ var TestManager = function(config, testFinishCallback) {
* message with something other then console.log
*
* @param {String} message
+ * @param {Boolean} [error]
*/
- this.log = function(message) {
+ this.log = function(message, error) {
if(config.log)
- config.log(message);
- else
- console.log(message);
+ config.log(message, error);
+ else {
+ if(error)
+ console.error(message);
+ else
+ console.log(message)
+ }
};
/**
@@ -130,7 +140,7 @@ var TestManager = function(config, testFinishCallback) {
*/
this.registerFailedtest = function(fail, err) {
this.fails.push(fail);
- this.log('- '+fail.name + " FAILED! \n"+fail.message);
+ this.log('- '+fail.name + " FAILED! \n"+fail.message, true);
if(err)
this.log(err);
this.log('');
@@ -175,15 +185,15 @@ var TestManager = function(config, testFinishCallback) {
var _checkIfFinished = function(manager) {
if(manager.tests.length == (manager.successes.length + manager.fails.length)) {
if(manager.fails.length == 0) {
- manager.log("\n------------------------------\nEverything is fine :)");
+ manager.log("\n------------------------------\n"+colors.green+"Everything is fine :)"+colors.reset);
manager.log('Executed a total of '+manager.successes.length+' successfull tests');
}
else {
- manager.log("\n------------------------------\nAll is not well :(");
- manager.log(manager.successes.length+' test'+(manager.successes.length > 1 ? 's':'')+' was successfull');
- manager.log(manager.fails.length+' test'+(manager.fails.length > 1 ? 's':'')+' failed');
+ manager.log("\n------------------------------\n"+colors.red+"All is not well :("+colors.reset, true);
+ manager.log(manager.successes.length+' test'+(manager.successes.length > 1 ? 's':'')+' was successfull', true);
+ manager.log(manager.fails.length+' test'+(manager.fails.length > 1 ? 's':'')+' failed', true);
for(var i=0; i < manager.fails.length; i++)
- manager.log(" - "+manager.fails[i].name+" ("+manager.fails[i].message+")");
+ manager.log(" - "+manager.fails[i].name+" ("+manager.fails[i].message+")", true);
}
manager.log("");
View
@@ -2,7 +2,7 @@
"author": "Victor Jonsson <kontakt@victorjonsson.se> (http://victorjonsson.se)",
"name": "dokimon",
"description": "This is a module used for setting up automated tests of various kinds. It may also be used as an alternative (or complement) to browser test tools such as Selenium. Write tests for a website or web service and manage them with a command line interface. Documentation available on github",
- "version": "0.0.17",
+ "version": "0.0.19",
"homepage": "https://github.com/victorjonsson/nodejs-dokimon",
"keywords": ["test","tests","scraping","node.js", "automation", "testing"],
"licenses": [{

0 comments on commit 50622d5

Please sign in to comment.