diff --git a/js/common/modules/jsunity.js b/js/common/modules/jsunity.js index 408ba95958..b0c7602fc1 100644 --- a/js/common/modules/jsunity.js +++ b/js/common/modules/jsunity.js @@ -33,6 +33,7 @@ var TOTAL = 0; var PASSED = 0; var FAILED = 0; var DURATION = 0; +var RESULTS = {}; var jsUnity = require("./jsunity/jsunity").jsUnity; @@ -40,14 +41,21 @@ jsUnity.results.begin = function (total, suiteName) { print("Running " + (suiteName || "unnamed test suite")); print(" " + total + " test(s) found"); print(); + RESULTS = {}; }; jsUnity.results.pass = function (index, testName) { print(internal.COLORS.COLOR_GREEN + " [PASSED] " + testName + internal.COLORS.COLOR_RESET); + RESULTS[testName] = {}; + RESULTS[testName].status = true; }; jsUnity.results.fail = function (index, testName, message) { 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) { @@ -108,30 +116,36 @@ function Run (tests) { suite.tearDown = tearDown; var result = jsUnity.run(suite); - TOTAL += result.total; PASSED += result.passed; FAILED += result.failed; DURATION += result.duration; + return RESULTS; } //////////////////////////////////////////////////////////////////////////////// /// @brief done with all tests //////////////////////////////////////////////////////////////////////////////// -function Done () { +function Done (suiteName) { // 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); print(); var ok = FAILED == 0; + RESULTS.duration = DURATION; + RESULTS.status = ok; + RESULTS.failed = FAILED; + RESULTS.total = TOTAL; + RESULTS.suiteName = suiteName; + TOTAL = 0; PASSED = 0; FAILED = 0; DURATION = 0; - return ok; + return RESULTS;//ok; } //////////////////////////////////////////////////////////////////////////////// @@ -151,7 +165,7 @@ function RunTest (path) { throw "cannot create context function"; } - return f(); + return f(path); } //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/modules/org/arangodb/testing.js b/js/server/modules/org/arangodb/testing.js index f1d97261d6..6dd1d107f6 100644 --- a/js/server/modules/org/arangodb/testing.js +++ b/js/server/modules/org/arangodb/testing.js @@ -1076,7 +1076,7 @@ function UnitTest (which, options) { ok = true; for (i in r) { if (r.hasOwnProperty(i)) { - if (r[i] !== 0 && r[i] !== true) { + if (r[i] !== 0 && r[i].status !== true) { ok = false; } } diff --git a/scripts/unittest.js b/scripts/unittest.js index 755d98f7d6..bf85dfd122 100644 --- a/scripts/unittest.js +++ b/scripts/unittest.js @@ -1,3 +1,6 @@ +var internalMembers = ["code", "error", "status", "duration", "failed", "total"]; + + function resultsToXml(results) { function xmlEscape(s) { return s.replace(/[<>&"]/g, function (c) { @@ -28,30 +31,34 @@ function resultsToXml(results) { 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) { - var result = results.shell_server_aql[i]; - var success = (typeof(result) === 'boolean')? result : false; - - xml.elem("testcase", { + xml.elem("testsuite", { + errors: 0, + failures: results.shell_server_aql[i].failed, name: i, - time: 0.0 - }, success); - - if (!success) { - xml.elem("failure", { message: result.message }, true) - .elem("/testcase"); - } - } + tests: results.shell_server_aql[i].total, + time: results.shell_server_aql[i].duration + }); - 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(""); }