Closed
Bug 580620
Opened 15 years ago
Closed 15 years ago
Implement a general assert function (to replace assertJS in nearly all cases)
Categories
(Testing Graveyard :: Mozmill, defect)
Testing Graveyard
Mozmill
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: whimboo, Assigned: whimboo)
References
Details
(Whiteboard: [mozmill-1.4.2+][mozmill-doc-complete])
Attachments
(1 file, 1 obsolete file)
|
2.12 KB,
patch
|
k0scist
:
review+
|
Details | Diff | Splinter Review |
Similar to bug 579943 it would helpful to also have a general assert function available which also gives us the chance to specify a closure function for the evaluation and to remove the eval expression.
Patch is upcoming in a minute...
| Assignee | ||
Comment 1•15 years ago
|
||
Attachment #459005 -
Flags: review?(jhammel)
Comment 2•15 years ago
|
||
Comment on attachment 459005 [details] [diff] [review]
Patch to introduce assert
>diff --git a/mozmill/mozmill/extension/resource/modules/controller.js b/mozmill/mozmill/extension/resource/modules/controller.js
>index e0b1e56..02cdacd 100644
>--- a/mozmill/mozmill/extension/resource/modules/controller.js
>+++ b/mozmill/mozmill/extension/resource/modules/controller.js
>@@ -55,6 +55,7 @@ var aConsoleService = Components.classes["@mozilla.org/consoleservice;1"].
>
> // Declare most used utils functions in the controller namespace
> var sleep = utils.sleep;
>+var assert = utils.assert;
> var waitFor = utils.waitFor;
> var waitForEval = utils.waitForEval;
>
>@@ -685,18 +686,24 @@ MozMillController.prototype.assertValue = function (el, value) {
> return false;
> };
>
>+/**
>+ * Check if the callback function evaluates to true
>+ */
>+MozMillController.prototype.assert = function(callback)
>+{
<snip/>
> //Assert that a provided value is selected in a select element
>diff --git a/mozmill/mozmill/extension/resource/modules/utils.js b/mozmill/mozmill/extension/resource/modules/utils.js
>index f3f3ce8..9cc9a71 100644
>--- a/mozmill/mozmill/extension/resource/modules/utils.js
>+++ b/mozmill/mozmill/extension/resource/modules/utils.js
>@@ -403,6 +403,19 @@ function sleep(milliseconds) {
> }
>
> /**
>+ * Check if the callback function evaluates to true
>+ */
>+MozMillController.prototype.assert = function(callback) {
Why is this also MozMillController.prototype.assert? Should it just be `function assert()`
>+ var result = callback();
>+
>+ if (!result) {
>+ throw new Error(arguments.callee.name + ": Failed for '" + callback + "'");
I'd prefer if this was a new error type, AssertionError, but its not that important
Comment 3•15 years ago
|
||
Comment on attachment 459005 [details] [diff] [review]
Patch to introduce assert
need clarification as to why you define MozMillController.prototype.assert twice (once in utils and once in controller)
Attachment #459005 -
Flags: review?(jhammel) → review-
Comment 4•15 years ago
|
||
We should look into implementing (stealing code from node/narwhal) the commonJS assert module for mozmill 2.0 http://wiki.commonjs.org/wiki/Unit_Testing/1.0#Assert.
| Assignee | ||
Comment 5•15 years ago
|
||
Attachment #459005 -
Attachment is obsolete: true
Attachment #460862 -
Flags: review?(jhammel)
Comment 6•15 years ago
|
||
Comment on attachment 460862 [details] [diff] [review]
Patch v2
looks good
Attachment #460862 -
Flags: review?(jhammel) → review+
| Assignee | ||
Comment 7•15 years ago
|
||
Merged with master and 1.4.2:
http://github.com/mozautomation/mozmill/commit/31ef72a6aba6324f4df052b125bd1e83dcb99fd2
http://github.com/mozautomation/mozmill/commit/cb6a77d77eb4540c1827f25b43c0e6755b94f3fe
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: [mozmill-1.4.2+] → [mozmill-1.4.2+][mozmill-doc-needed]
| Assignee | ||
Comment 8•15 years ago
|
||
We missed to declare this function inside exported symbols. I have landed a breakage fix:
http://github.com/mozautomation/mozmill/commit/304714b64270f1a7584f59d54475df7b459bee10
http://github.com/mozautomation/mozmill/commit/85379f77b48e08fd4ff0a763dbcebca2fcad6ece
Verified via running sample code for pass and fail
Status: RESOLVED → VERIFIED
| Assignee | ||
Comment 10•15 years ago
|
||
Documentation added:
https://developer.mozilla.org/en/Mozmill/Mozmill_Controller_Object#assert()
Whiteboard: [mozmill-1.4.2+][mozmill-doc-needed] → [mozmill-1.4.2+][mozmill-doc-complete]
Updated•9 years ago
|
Product: Testing → Testing Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•