mirror of https://gitee.com/bigwinds/arangodb
Add more information to the unittest status xml
This commit is contained in:
parent
772a99faec
commit
03ca3431e1
|
@ -33,6 +33,7 @@ var TOTAL = 0;
|
||||||
var PASSED = 0;
|
var PASSED = 0;
|
||||||
var FAILED = 0;
|
var FAILED = 0;
|
||||||
var DURATION = 0;
|
var DURATION = 0;
|
||||||
|
var RESULTS = {};
|
||||||
|
|
||||||
var jsUnity = require("./jsunity/jsunity").jsUnity;
|
var jsUnity = require("./jsunity/jsunity").jsUnity;
|
||||||
|
|
||||||
|
@ -40,14 +41,21 @@ jsUnity.results.begin = function (total, suiteName) {
|
||||||
print("Running " + (suiteName || "unnamed test suite"));
|
print("Running " + (suiteName || "unnamed test suite"));
|
||||||
print(" " + total + " test(s) found");
|
print(" " + total + " test(s) found");
|
||||||
print();
|
print();
|
||||||
|
RESULTS = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
jsUnity.results.pass = function (index, testName) {
|
jsUnity.results.pass = function (index, testName) {
|
||||||
print(internal.COLORS.COLOR_GREEN + " [PASSED] " + testName + internal.COLORS.COLOR_RESET);
|
print(internal.COLORS.COLOR_GREEN + " [PASSED] " + testName + internal.COLORS.COLOR_RESET);
|
||||||
|
RESULTS[testName] = {};
|
||||||
|
RESULTS[testName].status = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
jsUnity.results.fail = function (index, testName, message) {
|
jsUnity.results.fail = function (index, testName, message) {
|
||||||
print(internal.COLORS.COLOR_RED + " [FAILED] " + testName + ": " + message + internal.COLORS.COLOR_RESET);
|
print(internal.COLORS.COLOR_RED + " [FAILED] " + testName + ": " + message + internal.COLORS.COLOR_RESET);
|
||||||
|
RESULTS[testName] = {};
|
||||||
|
RESULTS[testName].status = false;
|
||||||
|
RESULTS[testName].message = message;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
jsUnity.results.end = function (passed, failed, duration) {
|
jsUnity.results.end = function (passed, failed, duration) {
|
||||||
|
@ -108,30 +116,36 @@ function Run (tests) {
|
||||||
suite.tearDown = tearDown;
|
suite.tearDown = tearDown;
|
||||||
|
|
||||||
var result = jsUnity.run(suite);
|
var result = jsUnity.run(suite);
|
||||||
|
|
||||||
TOTAL += result.total;
|
TOTAL += result.total;
|
||||||
PASSED += result.passed;
|
PASSED += result.passed;
|
||||||
FAILED += result.failed;
|
FAILED += result.failed;
|
||||||
DURATION += result.duration;
|
DURATION += result.duration;
|
||||||
|
return RESULTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief done with all tests
|
/// @brief done with all tests
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function Done () {
|
function Done (suiteName) {
|
||||||
// console.log("%d total, %d passed, %d failed, %d ms", TOTAL, PASSED, FAILED, DURATION);
|
// console.log("%d total, %d passed, %d failed, %d ms", TOTAL, PASSED, FAILED, DURATION);
|
||||||
internal.printf("%d total, %d passed, %d failed, %d ms", TOTAL, PASSED, FAILED, DURATION);
|
internal.printf("%d total, %d passed, %d failed, %d ms", TOTAL, PASSED, FAILED, DURATION);
|
||||||
print();
|
print();
|
||||||
|
|
||||||
var ok = FAILED == 0;
|
var ok = FAILED == 0;
|
||||||
|
|
||||||
|
RESULTS.duration = DURATION;
|
||||||
|
RESULTS.status = ok;
|
||||||
|
RESULTS.failed = FAILED;
|
||||||
|
RESULTS.total = TOTAL;
|
||||||
|
RESULTS.suiteName = suiteName;
|
||||||
|
|
||||||
TOTAL = 0;
|
TOTAL = 0;
|
||||||
PASSED = 0;
|
PASSED = 0;
|
||||||
FAILED = 0;
|
FAILED = 0;
|
||||||
DURATION = 0;
|
DURATION = 0;
|
||||||
|
|
||||||
return ok;
|
return RESULTS;//ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -151,7 +165,7 @@ function RunTest (path) {
|
||||||
throw "cannot create context function";
|
throw "cannot create context function";
|
||||||
}
|
}
|
||||||
|
|
||||||
return f();
|
return f(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1076,7 +1076,7 @@ function UnitTest (which, options) {
|
||||||
ok = true;
|
ok = true;
|
||||||
for (i in r) {
|
for (i in r) {
|
||||||
if (r.hasOwnProperty(i)) {
|
if (r.hasOwnProperty(i)) {
|
||||||
if (r[i] !== 0 && r[i] !== true) {
|
if (r[i] !== 0 && r[i].status !== true) {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
var internalMembers = ["code", "error", "status", "duration", "failed", "total"];
|
||||||
|
|
||||||
|
|
||||||
function resultsToXml(results) {
|
function resultsToXml(results) {
|
||||||
function xmlEscape(s) {
|
function xmlEscape(s) {
|
||||||
return s.replace(/[<>&"]/g, function (c) {
|
return s.replace(/[<>&"]/g, function (c) {
|
||||||
|
@ -28,30 +31,34 @@ function resultsToXml(results) {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
xml.elem("testsuite", {
|
|
||||||
errors: 0,
|
|
||||||
failures: results.failed,
|
|
||||||
name: results.suiteName,
|
|
||||||
tests: results.total,
|
|
||||||
time: results.duration
|
|
||||||
});
|
|
||||||
|
|
||||||
for (var i in results.shell_server_aql) {
|
for (var i in results.shell_server_aql) {
|
||||||
var result = results.shell_server_aql[i];
|
xml.elem("testsuite", {
|
||||||
var success = (typeof(result) === 'boolean')? result : false;
|
errors: 0,
|
||||||
|
failures: results.shell_server_aql[i].failed,
|
||||||
xml.elem("testcase", {
|
|
||||||
name: i,
|
name: i,
|
||||||
time: 0.0
|
tests: results.shell_server_aql[i].total,
|
||||||
}, success);
|
time: results.shell_server_aql[i].duration
|
||||||
|
});
|
||||||
if (!success) {
|
|
||||||
xml.elem("failure", { message: result.message }, true)
|
|
||||||
.elem("/testcase");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xml.elem("/testsuite");
|
for (var j in results.shell_server_aql[i]) {
|
||||||
|
if (internalMembers.indexOf(j) === -1) {
|
||||||
|
var result = results.shell_server_aql[i][j].status;
|
||||||
|
var success = (typeof(result) === 'boolean')? result : false;
|
||||||
|
|
||||||
|
xml.elem("testcase", {
|
||||||
|
name: j,
|
||||||
|
time: 0.0
|
||||||
|
}, success);
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
xml.elem("failure", { message: results.shell_server_aql[i][j].message }, true)
|
||||||
|
.elem("/testcase");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xml.elem("/testsuite");
|
||||||
|
}
|
||||||
|
|
||||||
return xml.join("");
|
return xml.join("");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue