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 COMPLETE = {};
|
||||
|
||||
var SETUPS = 0;
|
||||
var TEARDOWNS = 0;
|
||||
|
||||
var TOTALSETUPS = 0;
|
||||
var TOTALTEARDOWNS = 0;
|
||||
|
||||
var jsUnity = require('./jsunity/jsunity').jsUnity;
|
||||
var STARTTEST = 0.0;
|
||||
var testFilter = "undefined";
|
||||
|
@ -58,7 +64,6 @@ jsUnity.results.begin = function (total, suiteName) {
|
|||
jsUnity.results.pass = function (index, testName) {
|
||||
var newtime = jsUnity.env.getDate();
|
||||
|
||||
RESULTS[testName] = {};
|
||||
RESULTS[testName].status = true;
|
||||
RESULTS[testName].duration = newtime - STARTTEST;
|
||||
|
||||
|
@ -71,7 +76,6 @@ jsUnity.results.pass = function (index, testName) {
|
|||
jsUnity.results.fail = function (index, testName, message) {
|
||||
var newtime = jsUnity.env.getDate();
|
||||
|
||||
RESULTS[testName] = {};
|
||||
RESULTS[testName].status = false;
|
||||
RESULTS[testName].message = message;
|
||||
RESULTS[testName].duration = newtime - STARTTEST;
|
||||
|
@ -93,6 +97,22 @@ jsUnity.results.end = function (passed, failed, duration) {
|
|||
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
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -151,10 +171,12 @@ function Run (testsuite) {
|
|||
suiteName: suite.suiteName,
|
||||
message: err,
|
||||
duration: 0,
|
||||
setUpDuration: 0,
|
||||
tearDownDuration: 0,
|
||||
passed: 0,
|
||||
status: false,
|
||||
failed: 1,
|
||||
total: 1,
|
||||
total: 1
|
||||
};
|
||||
TOTAL += 1;
|
||||
FAILED += 2;
|
||||
|
@ -176,6 +198,7 @@ function Run (testsuite) {
|
|||
FAILED += result.failed;
|
||||
DURATION += result.duration;
|
||||
|
||||
|
||||
let duplicates = [];
|
||||
for (var attrname in RESULTS) {
|
||||
if (RESULTS.hasOwnProperty(attrname)) {
|
||||
|
@ -207,6 +230,8 @@ function Done (suiteName) {
|
|||
COMPLETE.failed = FAILED;
|
||||
COMPLETE.total = TOTAL;
|
||||
COMPLETE.suiteName = suiteName;
|
||||
COMPLETE.totalSetUp = TOTALSETUPS;
|
||||
COMPLETE.totalTearDown = TOTALTEARDOWNS;
|
||||
|
||||
TOTAL = 0;
|
||||
PASSED = 0;
|
||||
|
|
|
@ -378,6 +378,10 @@ var jsUnity = exports.jsUnity = (function () {
|
|||
jsUnity.log.info(plural(total, "test") + " found");
|
||||
},
|
||||
|
||||
beginSetUp: function(index, testName) {},
|
||||
|
||||
endSetUp: function(index, testName) {},
|
||||
|
||||
pass: function (index, testName) {
|
||||
jsUnity.tap.write(fmt("ok ? - ?", index, testName));
|
||||
jsUnity.log.info("[PASSED] " + testName);
|
||||
|
@ -391,6 +395,10 @@ var jsUnity = exports.jsUnity = (function () {
|
|||
jsUnity.log.info(fmt("[FAILED] ?: ?", testName, message));
|
||||
},
|
||||
|
||||
beginTeardown: function(index, testName) {},
|
||||
|
||||
endTeardown: function(index, testName) {},
|
||||
|
||||
end: function (passed, failed, duration) {
|
||||
jsUnity.log.info(plural(passed, "test") + " passed");
|
||||
jsUnity.log.info(plural(failed, "test") + " failed");
|
||||
|
@ -517,9 +525,16 @@ var jsUnity = exports.jsUnity = (function () {
|
|||
counter = 0;
|
||||
|
||||
try {
|
||||
this.results.beginSetUp(suite.scope, test.name);
|
||||
setUp(test.name);
|
||||
this.results.endSetUp(suite.scope, test.name);
|
||||
|
||||
test.fn.call(suite.scope, test.name);
|
||||
|
||||
|
||||
this.results.beginTeardown(suite.scope, test.name);
|
||||
tearDown(test.name);
|
||||
this.results.endTeardown(suite.scope, test.name);
|
||||
|
||||
this.results.pass(j + 1, test.name);
|
||||
|
||||
|
|
Loading…
Reference in New Issue