Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: aecba504a7
Fetching contributors…

Cannot retrieve contributors at this time

137 lines (112 sloc) 4.896 kb
<!DOCTYPE html>
<html>
<head>
<title>YUI Test</title>
<!-- JS -->
<script src="../build/parserlib.js"></script>
<script src="../lib/yuitest.js"></script>
<script src="../build/parserlib-tests.js"></script>
<style type="text/css">
.passed {
color: green;
}
.failed, .error {
color: red;
}
.ignored {
color: silver;
}
</style>
</head>
<body>
<div id="doc">
<h1>YUI Test - Test Runner</h1>
<button id="run">Run</button>
<h2>Results</h2>
<ul id="results"></ul>
</div>
<script >
(function(){
//some helpful variables
var runButton = document.getElementById("run"),
resultsList = document.getElementById("results"),
resultNode = resultsList,
events = [
YUITest.TestRunner.TEST_CASE_BEGIN_EVENT,
YUITest.TestRunner.TEST_CASE_COMPLETE_EVENT,
YUITest.TestRunner.TEST_SUITE_BEGIN_EVENT,
YUITest.TestRunner.TEST_SUITE_COMPLETE_EVENT,
YUITest.TestRunner.TEST_PASS_EVENT,
YUITest.TestRunner.TEST_FAIL_EVENT,
YUITest.TestRunner.TEST_IGNORE_EVENT,
YUITest.TestRunner.COMPLETE_EVENT,
YUITest.TestRunner.BEGIN_EVENT,
YUITest.TestRunner.ERROR_EVENT
];
for (var i=0; i < events.length; i++){
YUITest.TestRunner.attach(events[i], function(event){
var node;
switch(event.type){
case this.BEGIN_EVENT:
message = "Testing began at " + (new Date()).toString() + ".";
messageType = "info";
break;
case this.COMPLETE_EVENT:
message = "Testing completed at " + (new Date()).toString() + ".\nPassed:" +
event.results.passed + " Failed:" + event.results.failed + " Total:" + event.results.total;
messageType = "info";
break;
case this.TEST_FAIL_EVENT:
node = document.createElement("li");
node.className = "failed";
node.innerHTML = event.testName + ": " + event.error.getMessage().replace(/\n/g, "<br>");
resultNode.appendChild(node);
break;
case this.ERROR_EVENT:
node = document.createElement("li");
node.className = "error";
node.innerHTML = "ERROR: " + event.methodName + "() caused an error: " + event.error.message.replace(/\n/g, "<br>");
resultNode.appendChild(node);
break;
case this.TEST_IGNORE_EVENT:
node = document.createElement("li");
node.className = "ignored";
node.innerHTML = event.testName;
resultNode.appendChild(node);
break;
case this.TEST_PASS_EVENT:
node = document.createElement("li");
node.className = "passed";
node.innerHTML = event.testName;
resultNode.appendChild(node);
break;
case this.TEST_SUITE_BEGIN_EVENT:
node = document.createElement("li");
node.innerHTML = event.testSuite.name;
resultNode.appendChild(node);
resultNode = resultNode.appendChild(document.createElement("ul"));
break;
case this.TEST_CASE_COMPLETE_EVENT:
case this.TEST_SUITE_COMPLETE_EVENT:
resultNode.previousSibling.innerHTML += " (passed: " + event.results.passed + ", failed: " + event.results.failed + ", total: " + event.results.total + ", errors: " + event.results.errors + ", ignored: " + event.results.ignored + ")";
resultNode = resultNode.parentNode;
break;
case this.TEST_CASE_BEGIN_EVENT:
node = document.createElement("li");
node.innerHTML = event.testCase.name;
resultNode.appendChild(node);
resultNode = resultNode.appendChild(document.createElement("ul"));
break;
}
});
}
runButton.onclick = function(){
//reset the interface
resultsList.innerHTML = "";
resultNode = resultsList;
YUITest.TestRunner.run();
};
})();
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.