cleaned up test suite index html, added reporting for failed and successfull tests at the suite level

This commit is contained in:
John Bender 2011-08-13 00:50:16 -07:00
parent c5c89344ad
commit a197e17500
2 changed files with 41 additions and 10 deletions

View file

@ -6,17 +6,35 @@
<script src="../../js/jquery.js"></script>
<script src="../../external/qunit.js"></script>
<script src="runner.js"></script>
<style type="text/css">
html, body {
width:100%;
height:100%;
margin:0px;
padding:0px;
}
#testFrame {
float: left;
border: 0px;
height: 100%;
width: 60%;
}
#results {
float: left;
width: 30%;
}
</style>
</head>
<body>
<div style="float: left; width: 500px;">
<div id="results">
<h1 id="qunit-header"><a href="#">jQuery Mobile Test Suite</a></h1>
<h2 id="qunit-banner"></h2>
<ol id="qunit-tests">
</ol>
</div>
<!-- under normal circumstances inline styles would be a poor choice, but in this case
I think an entire link and stylesheet is a waste -->
<iframe data-src="../../tests/unit/{{testdir}}" name="testFrame" id="testFrame" width="800px" height="100%" style="float: left; border: 0px; height: 100%;" scrolling="no">
<iframe data-src="../../tests/unit/{{testdir}}" name="testFrame" id="testFrame" scrolling="no">
</iframe>
</body>
</html>

View file

@ -9,6 +9,8 @@ $(function() {
$frameElem: $( "#testFrame" ),
assertionResultPrefix: "assertion result for test:",
onTimeout: QUnit.start,
onFrameLoad: function() {
@ -18,30 +20,41 @@ $(function() {
// when the QUnit object reports done in the iframe
// run the onFrameDone method
self.frame.QUnit.done = self.onFrameDone;
self.frame.QUnit.testDone = self.onTestDone;
},
onTestDone: function( name, bad, assertCount ) {
QUnit.ok( !bad, name );
self.recordAssertions( assertCount - 1, name );
},
onFrameDone: function( failed, passed, total, runtime ){
// record success
self.recordResult( false , failed );
self.recordResult( true , passed );
// make sure we don't time out the tests
clearTimeout( self.testTimer );
// TODO decipher actual cause of multiple test results firing twice
// clear the done call to prevent early completion of other test cases
self.frame.QUnit.done = $.noop;
self.frame.QUnit.testDone = $.noop;
// hide the extra assertions made to propogate the count
// to the suite level test
self.hideAssertionResults();
// continue on to the next suite
QUnit.start();
},
recordResult: function( result, count ) {
recordAssertions: function( count, parentTest ) {
for( var i = 0; i < count; i++ ) {
ok( result );
ok( true, self.assertionResultPrefix + parentTest );
}
},
hideAssertionResults: function() {
$( "li:not([id]):contains('" + self.assertionResultPrefix + "')" ).hide();
},
exec: function( data ) {
var template = self.$frameElem.attr( "data-src" );