mirror of https://gitee.com/bigwinds/arangodb
record the times used for the setup/teardown methods of jsunity tests; exposed to the json report file to be enabled along with the junit xml report files. (#8838)
This commit is contained in:
parent
2ec9a9d55a
commit
6984daf67b
|
@ -38,6 +38,12 @@ var DURATION = 0;
|
||||||
var RESULTS = {};
|
var RESULTS = {};
|
||||||
var COMPLETE = {};
|
var COMPLETE = {};
|
||||||
|
|
||||||
|
var SETUPS = 0;
|
||||||
|
var TEARDOWNS = 0;
|
||||||
|
|
||||||
|
var TOTALSETUPS = 0;
|
||||||
|
var TOTALTEARDOWNS = 0;
|
||||||
|
|
||||||
var jsUnity = require('./jsunity/jsunity').jsUnity;
|
var jsUnity = require('./jsunity/jsunity').jsUnity;
|
||||||
var STARTTEST = 0.0;
|
var STARTTEST = 0.0;
|
||||||
var testFilter = "undefined";
|
var testFilter = "undefined";
|
||||||
|
@ -58,7 +64,6 @@ jsUnity.results.begin = function (total, suiteName) {
|
||||||
jsUnity.results.pass = function (index, testName) {
|
jsUnity.results.pass = function (index, testName) {
|
||||||
var newtime = jsUnity.env.getDate();
|
var newtime = jsUnity.env.getDate();
|
||||||
|
|
||||||
RESULTS[testName] = {};
|
|
||||||
RESULTS[testName].status = true;
|
RESULTS[testName].status = true;
|
||||||
RESULTS[testName].duration = newtime - STARTTEST;
|
RESULTS[testName].duration = newtime - STARTTEST;
|
||||||
|
|
||||||
|
@ -71,7 +76,6 @@ jsUnity.results.pass = function (index, testName) {
|
||||||
jsUnity.results.fail = function (index, testName, message) {
|
jsUnity.results.fail = function (index, testName, message) {
|
||||||
var newtime = jsUnity.env.getDate();
|
var newtime = jsUnity.env.getDate();
|
||||||
|
|
||||||
RESULTS[testName] = {};
|
|
||||||
RESULTS[testName].status = false;
|
RESULTS[testName].status = false;
|
||||||
RESULTS[testName].message = message;
|
RESULTS[testName].message = message;
|
||||||
RESULTS[testName].duration = newtime - STARTTEST;
|
RESULTS[testName].duration = newtime - STARTTEST;
|
||||||
|
@ -93,6 +97,22 @@ jsUnity.results.end = function (passed, failed, duration) {
|
||||||
print();
|
print();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
jsUnity.results.beginSetUp = function(index, testName) {
|
||||||
|
RESULTS[testName] = {};
|
||||||
|
SETUPS = jsUnity.env.getDate();
|
||||||
|
};
|
||||||
|
jsUnity.results.endSetUp = function(index, testName) {
|
||||||
|
RESULTS[testName].setUpDuration = jsUnity.env.getDate() - SETUPS;
|
||||||
|
TOTALSETUPS += RESULTS[testName].setUpDuration;
|
||||||
|
};
|
||||||
|
jsUnity.results.beginTeardown = function(index, testName) {
|
||||||
|
TEARDOWNS = jsUnity.env.getDate();
|
||||||
|
};
|
||||||
|
jsUnity.results.endTeardown = function(index, testName) {
|
||||||
|
RESULTS[testName].tearDownDuration = jsUnity.env.getDate() - TEARDOWNS;
|
||||||
|
TOTALTEARDOWNS += RESULTS[testName].tearDownDuration;
|
||||||
|
};
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////
|
||||||
// / @brief runs a test with context
|
// / @brief runs a test with context
|
||||||
// //////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -151,10 +171,12 @@ function Run (testsuite) {
|
||||||
suiteName: suite.suiteName,
|
suiteName: suite.suiteName,
|
||||||
message: err,
|
message: err,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
|
setUpDuration: 0,
|
||||||
|
tearDownDuration: 0,
|
||||||
passed: 0,
|
passed: 0,
|
||||||
status: false,
|
status: false,
|
||||||
failed: 1,
|
failed: 1,
|
||||||
total: 1,
|
total: 1
|
||||||
};
|
};
|
||||||
TOTAL += 1;
|
TOTAL += 1;
|
||||||
FAILED += 2;
|
FAILED += 2;
|
||||||
|
@ -175,7 +197,8 @@ function Run (testsuite) {
|
||||||
PASSED += result.passed;
|
PASSED += result.passed;
|
||||||
FAILED += result.failed;
|
FAILED += result.failed;
|
||||||
DURATION += result.duration;
|
DURATION += result.duration;
|
||||||
|
|
||||||
|
|
||||||
let duplicates = [];
|
let duplicates = [];
|
||||||
for (var attrname in RESULTS) {
|
for (var attrname in RESULTS) {
|
||||||
if (RESULTS.hasOwnProperty(attrname)) {
|
if (RESULTS.hasOwnProperty(attrname)) {
|
||||||
|
@ -207,6 +230,8 @@ function Done (suiteName) {
|
||||||
COMPLETE.failed = FAILED;
|
COMPLETE.failed = FAILED;
|
||||||
COMPLETE.total = TOTAL;
|
COMPLETE.total = TOTAL;
|
||||||
COMPLETE.suiteName = suiteName;
|
COMPLETE.suiteName = suiteName;
|
||||||
|
COMPLETE.totalSetUp = TOTALSETUPS;
|
||||||
|
COMPLETE.totalTearDown = TOTALTEARDOWNS;
|
||||||
|
|
||||||
TOTAL = 0;
|
TOTAL = 0;
|
||||||
PASSED = 0;
|
PASSED = 0;
|
||||||
|
|
|
@ -378,6 +378,10 @@ var jsUnity = exports.jsUnity = (function () {
|
||||||
jsUnity.log.info(plural(total, "test") + " found");
|
jsUnity.log.info(plural(total, "test") + " found");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
beginSetUp: function(index, testName) {},
|
||||||
|
|
||||||
|
endSetUp: function(index, testName) {},
|
||||||
|
|
||||||
pass: function (index, testName) {
|
pass: function (index, testName) {
|
||||||
jsUnity.tap.write(fmt("ok ? - ?", index, testName));
|
jsUnity.tap.write(fmt("ok ? - ?", index, testName));
|
||||||
jsUnity.log.info("[PASSED] " + testName);
|
jsUnity.log.info("[PASSED] " + testName);
|
||||||
|
@ -390,7 +394,11 @@ var jsUnity = exports.jsUnity = (function () {
|
||||||
jsUnity.tap.write(" ...");
|
jsUnity.tap.write(" ...");
|
||||||
jsUnity.log.info(fmt("[FAILED] ?: ?", testName, message));
|
jsUnity.log.info(fmt("[FAILED] ?: ?", testName, message));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
beginTeardown: function(index, testName) {},
|
||||||
|
|
||||||
|
endTeardown: function(index, testName) {},
|
||||||
|
|
||||||
end: function (passed, failed, duration) {
|
end: function (passed, failed, duration) {
|
||||||
jsUnity.log.info(plural(passed, "test") + " passed");
|
jsUnity.log.info(plural(passed, "test") + " passed");
|
||||||
jsUnity.log.info(plural(failed, "test") + " failed");
|
jsUnity.log.info(plural(failed, "test") + " failed");
|
||||||
|
@ -517,9 +525,16 @@ var jsUnity = exports.jsUnity = (function () {
|
||||||
counter = 0;
|
counter = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
this.results.beginSetUp(suite.scope, test.name);
|
||||||
setUp(test.name);
|
setUp(test.name);
|
||||||
|
this.results.endSetUp(suite.scope, test.name);
|
||||||
|
|
||||||
test.fn.call(suite.scope, test.name);
|
test.fn.call(suite.scope, test.name);
|
||||||
|
|
||||||
|
|
||||||
|
this.results.beginTeardown(suite.scope, test.name);
|
||||||
tearDown(test.name);
|
tearDown(test.name);
|
||||||
|
this.results.endTeardown(suite.scope, test.name);
|
||||||
|
|
||||||
this.results.pass(j + 1, test.name);
|
this.results.pass(j + 1, test.name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue