added assertNotEquals, the inverse of assertEquals
Showing
1 changed file
with
35 additions
and
0 deletions
... | @@ -141,6 +141,41 @@ var Tester = function Tester(casper, options) { | ... | @@ -141,6 +141,41 @@ var Tester = function Tester(casper, options) { |
141 | } | 141 | } |
142 | }); | 142 | }); |
143 | }; | 143 | }; |
144 | |||
145 | /** | ||
146 | * Asserts that two values are strictly not equals. | ||
147 | * | ||
148 | * @param Mixed subject The value to test | ||
149 | * @param Mixed expected The unwanted value | ||
150 | * @param String message Test description | ||
151 | */ | ||
152 | |||
153 | this.assertNotEquals = function assertNotEquals(subject, shouldnt, message) { | ||
154 | var eventName; | ||
155 | message = message || ""; | ||
156 | if (!this.testEquals(subject, shouldnt)) { | ||
157 | eventName = "success"; | ||
158 | casper.echo(this.colorize(this.options.passText, 'INFO') + ' ' + this.formatMessage(message)); | ||
159 | this.testResults.passed++; | ||
160 | } else { | ||
161 | eventName = "fail"; | ||
162 | casper.echo(this.colorize(this.options.failText, 'RED_BAR') + ' ' + this.formatMessage(message, 'WARNING')); | ||
163 | this.comment(' got: ' + utils.serialize(subject)); | ||
164 | this.comment(' shouldnt: ' + utils.serialize(shouldnt)); | ||
165 | this.testResults.failed++; | ||
166 | } | ||
167 | this.emit(eventName, { | ||
168 | type: "assertNotEquals", | ||
169 | message: message, | ||
170 | details: f("test failed; shouldnt: %s; got: %s", shouldnt, subject), | ||
171 | file: this.currentTestFile, | ||
172 | values: { | ||
173 | subject: subject, | ||
174 | shouldnt: shouldnt | ||
175 | } | ||
176 | }); | ||
177 | }; | ||
178 | |||
144 | 179 | ||
145 | /** | 180 | /** |
146 | * Asserts that a code evaluation in remote DOM resolves to true. | 181 | * Asserts that a code evaluation in remote DOM resolves to true. | ... | ... |
-
Please register or sign in to post a comment