Permalink
Browse files

Updated comparison failure behavior

  • Loading branch information...
1 parent 41a88fc commit d717f45214bfd00511d25c7d30637c3c32faa73f Nicholas C. Zakas committed Oct 10, 2009
Showing with 13 additions and 5 deletions.
  1. +7 −3 yuitest-fireunit/yui2/yuitest-fireunit.htm
  2. +6 −2 yuitest-fireunit/yui2/yuitest-fireunit.js
@@ -14,7 +14,7 @@
<p><input type="button" value="Run Tests" id="btnRun" /></p>
<p style="width:50%">The results for the unit tests will be output into the <a href="http://www.fireunit.org">FireUnit</a> console. You must
have FireUnit installed for this example to work. FireUnit requires Firefox 3+ and Firebug 1.2+. The logger
-is included to show the normal YUI Test output.</p>
+is included to show the normal YUI Test output. There are two tests that fail on purpose to show the output from a failed test.</p>
<script type="text/javascript">
YAHOO.namespace("test");
@@ -342,7 +342,9 @@
Profiler.unregisterFunction("testObject.factorial");
Assert.isObject(report, "Report should be an object.");
- Assert.isNumber(report.calls, "Call count should be a number.");
+
+ //intentional failure
+ Assert.isObject(report.calls, "Call count should be a number.");
Assert.isNumber(report.max, "Max should be a number.");
Assert.isNumber(report.min, "Min should be a number.");
Assert.isNumber(report.avg, "Average should be a number.");
@@ -359,7 +361,9 @@
Profiler.unregisterFunction("testObject.factorial");
Assert.isObject(report, "Report should be an object.");
- Assert.areEqual(10, report.calls, "Report.calls is incorrect.");
+
+ //intentional failure
+ Assert.areEqual(11, report.calls, "Report.calls is incorrect.");
Assert.areEqual(10, callCount, "Call count is incorrect.");
},
@@ -41,8 +41,12 @@ YAHOO.tool.FireUnit = function(){
case "pass":
fireunit.ok(true, event.testName + " passed.");
break;
- case "fail":
- fireunit.ok(false, event.testName + "failed: " + event.error.getMessage());
+ case "fail":
+ if (event.error instanceof YAHOO.util.ComparisonFailure){
+ fireunit.ok(false, event.testName + "failed: " + event.error.message, event.error.expected, event.error.actual);
+ } else {
+ fireunit.ok(false, event.testName + "failed: " + event.error.message);
+ }
break;
case "testsuitebegin":
fireunit.group(event.testSuite.name);

0 comments on commit d717f45

Please sign in to comment.