Skip to content
Permalink
Browse files

Fixed query decoding in HTML runner. Added Rhino runner.

  • Loading branch information...
atesgoral committed Sep 25, 2009
1 parent fedee5d commit d02ea194d500ed2834d7b59f1526feb2c6ac4a45
Showing with 70 additions and 1 deletion.
  1. +1 −1 runners/html/runner.js
  2. +69 −0 runners/rhino/runner.js
@@ -1,6 +1,6 @@
function getQueryParams(qs) {
function decode(s) {
return decodeURIComponent(s).split("+").join(" ");
return decodeURIComponent(s.split("+").join(" "));
}

var params = {};
@@ -0,0 +1,69 @@
function resultsToXml(results) {
function xmlEscape(s) {
return s.replace(/[<>&"]/g, function (c) {
return "&"
+ { "<": "lt", ">": "gt", "&": "amp", "\"": "quot" }[c]
+ ";";
});
}

var xml = [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ];

xml.text = function (s) {
Array.prototype.push.call(this, s);
return this;
};

xml.elem = function (tagName, attrs, close) {
this.text("<").text(tagName);

for (var a in attrs || {}) {
this.text(" ").text(a).text("=\"")
.text(xmlEscape(String(attrs[a]))).text("\"");
}

close && this.text("/");
this.text(">\n");

return this;
};

xml.elem("testsuite", {
errors: 0,
failures: results.failed,
name: results.suiteName,
tests: results.total,
time: results.duration
});

for (var i = 0; i < results.tests.length; i++) {
var test = results.tests[i];

xml.elem("testcase", {
name: test.name,
time: test.duration
}, test.passed);

if (!test.passed) {
xml.elem("failure", { message: test.failureMessage }, true)
.elem("/testcase");
}
}

xml.elem("/testsuite");

return xml.join("");
}

load(arguments[0]);

load("../../jsunity.js");

jsUnity.log = print;
jsUnity.attachAssertions(this);

var results = jsUnity.run(testSuite);

if (results) {
print(resultsToXml(results));
}

0 comments on commit d02ea19

Please sign in to comment.
You can’t perform that action at this time.