Skip to content

Commit

Permalink
Add time attribute in Junit Reporter #275
Browse files Browse the repository at this point in the history
- Convert curModule.testcases from array to dictionary;
- Set 'start' end 'end' at suites and testcases;
  • Loading branch information
hugosenari committed Nov 28, 2014
1 parent 60b7d67 commit fc3a271
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/reporters/junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ exports.run = function (files, opts, callback) {
return path.resolve(p);
});

var modules = {}
var modules = {};
var curModule;

nodeunit.runFiles(paths, {
Expand All @@ -108,13 +108,21 @@ exports.run = function (files, opts, callback) {
errorCount: 0,
failureCount: 0,
tests: 0,
testcases: [],
name: name
testcases: {},
name: name,
start: new Date().getTime()
};
modules[name] = curModule;
},
testStart: function(name) {
curModule.testcases[name] = {name: name, start : new Date().getTime()};
},
moduleDone: function(name) {
curModule.end = new Date().getTime();
},
testDone: function (name, assertions) {
var testcase = {name: name};
var testcase = curModule.testcases[name];
testcase.end = new Date().getTime();
for (var i=0; i<assertions.length; i++) {
var a = assertions[i];
if (a.failed()) {
Expand All @@ -134,7 +142,7 @@ exports.run = function (files, opts, callback) {
}
}
curModule.tests++;
curModule.testcases.push(testcase);
curModule.testcases[name] = testcase;;
},
done: function (assertions) {
var end = new Date().getTime();
Expand Down

0 comments on commit fc3a271

Please sign in to comment.