forked from CSSLint/csslint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request CSSLint#478 from XhmikosR/testrunner
Update testrunner.htm.
- Loading branch information
Showing
1 changed file
with
116 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,138 +1,131 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>YUI Test</title> | ||
|
||
<!-- JS --> | ||
<script src="../build/csslint.js"></script> | ||
<script src="../lib/yuitest.js"></script> | ||
<script src="../build/csslint-tests.js"></script> | ||
<script src="all-rules.js"></script> | ||
<style type="text/css"> | ||
.passed { | ||
color: green; | ||
} | ||
|
||
.failed, .error { | ||
color: red; | ||
} | ||
|
||
.ignored { | ||
color: silver; | ||
} | ||
</style> | ||
<meta charset="utf-8"> | ||
<title>YUI Test</title> | ||
|
||
<!-- JS --> | ||
<script src="../build/csslint.js"></script> | ||
<script src="../lib/yuitest.js"></script> | ||
<script src="../build/csslint-tests.js"></script> | ||
<script src="all-rules.js"></script> | ||
<style> | ||
.passed { color: green; } | ||
.failed, .error { color: red; } | ||
.ignored { color: silver; } | ||
</style> | ||
|
||
</head> | ||
<body> | ||
<div id="doc"> | ||
<h1>YUI Test - Test Runner</h1> | ||
<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> | ||
<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> | ||
</html> |