Closed
Bug 578301
Opened 15 years ago
Closed 15 years ago
Clearly identify expected and actual results when tests fail
Categories
(Testing :: Mochitest, defect)
Testing
Mochitest
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla2.0b2
People
(Reporter: dao, Assigned: dao)
References
Details
(Keywords: regression)
Attachments
(1 file)
2.35 KB,
patch
|
dbaron
:
review+
|
Details | Diff | Splinter Review |
"foo should equal bar" continues to confuse me...
Assignee | ||
Comment 1•15 years ago
|
||
Attachment #457035 -
Flags: review?
Assignee | ||
Comment 2•15 years ago
|
||
Comment on attachment 457035 [details] [diff] [review]
patch
>diff --git a/testing/mochitest/tests/SimpleTest/SimpleTest.js b/testing/mochitest/tests/SimpleTest/SimpleTest.js
>--- a/testing/mochitest/tests/SimpleTest/SimpleTest.js
>+++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js
>@@ -50,22 +50,28 @@ SimpleTest.ok = function (condition, nam
> SimpleTest._tests.push(test);
> };
>
> /**
> * Roughly equivalent to ok(a==b, name)
> **/
> SimpleTest.is = function (a, b, name) {
> var repr = MochiKit.Base.repr;
>- SimpleTest.ok(a == b, name, repr(a) + " should equal " + repr(b));
>+ var pass = (a == b);
>+ var diag = pass ? repr(a) + " should equal " + repr(b)
>+ : "got " + repr(a) + ", expected " + repr(b)
>+ SimpleTest.ok(pass, name, diag);
> };
>
> SimpleTest.isnot = function (a, b, name) {
> var repr = MochiKit.Base.repr;
>- SimpleTest.ok(a != b, name, repr(a) + " should not equal " + repr(b));
>+ var pass = (a != b);
>+ var diag = pass ? repr(a) + " should not equal " + repr(b)
>+ : "didn't expect " + repr(a) + ", but got it";
>+ SimpleTest.ok(pass, name, diag);
> };
>
> // --------------- Test.Builder/Test.More todo() -----------------
>
> SimpleTest.todo = function(condition, name, diag) {
> var test = {'result': !!condition, 'name': name, 'diag': diag, todo: true};
> if (SimpleTest._logEnabled)
> SimpleTest._logResult(test, "TEST-UNEXPECTED-PASS", "TEST-KNOWN-FAIL");
>@@ -94,22 +100,28 @@ SimpleTest._logResult = function(test, p
> };
>
> /**
> * Copies of is and isnot with the call to ok replaced by a call to todo.
> **/
>
> SimpleTest.todo_is = function (a, b, name) {
> var repr = MochiKit.Base.repr;
>- SimpleTest.todo(a == b, name, repr(a) + " should equal " + repr(b));
>+ var pass = (a == b);
>+ var diag = pass ? repr(a) + " should equal " + repr(b)
>+ : "got " + repr(a) + ", expected " + repr(b);
>+ SimpleTest.todo(pass, name, diag);
> };
>
> SimpleTest.todo_isnot = function (a, b, name) {
> var repr = MochiKit.Base.repr;
>- SimpleTest.todo(a != b, name, repr(a) + " should not equal " + repr(b));
>+ var pass = (a != b);
>+ var diag = pass ? repr(a) + " should not equal " + repr(b)
>+ : "didn't expect " + repr(a) + ", but got it";
>+ SimpleTest.todo(pass, name, diag);
> };
>
>
> /**
> * Makes a test report, returns it as a DIV element.
> **/
> SimpleTest.report = function () {
> var DIV = MochiKit.DOM.DIV;
Attachment #457035 -
Flags: review? → review?(dbaron)
Comment on attachment 457035 [details] [diff] [review]
patch
r=dbaron (a little reluctantly, though)
Attachment #457035 -
Flags: review?(dbaron) → review+
Assignee | ||
Comment 4•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3b2
You need to log in
before you can comment on or make changes to this bug.
Description
•