OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Integration module for QUnit tests running in browser tests. | 7 * Integration module for QUnit tests running in browser tests. |
8 * Specifically it: | 8 * Specifically it: |
9 * - Sets QUnit.autostart to false, so that the browser test can hook the test | 9 * - Sets QUnit.autostart to false, so that the browser test can hook the test |
10 * results callback before the test starts. | 10 * results callback before the test starts. |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 TestReporter.prototype.init = function(qunit) { | 27 TestReporter.prototype.init = function(qunit) { |
28 qunit.testStart(this.onTestStart_.bind(this)); | 28 qunit.testStart(this.onTestStart_.bind(this)); |
29 qunit.testDone(this.onTestDone_.bind(this)); | 29 qunit.testDone(this.onTestDone_.bind(this)); |
30 qunit.log(this.onAssertion_.bind(this)); | 30 qunit.log(this.onAssertion_.bind(this)); |
31 }; | 31 }; |
32 | 32 |
33 /** | 33 /** |
34 * @param {{ module:string, name: string }} details | 34 * @param {{ module:string, name: string }} details |
35 */ | 35 */ |
36 TestReporter.prototype.onTestStart_ = function(details) { | 36 TestReporter.prototype.onTestStart_ = function(details) {}; |
37 console.log('[===============]'); | |
38 console.log('[------RUN------] ' + details.module + '.' + details.name); | |
39 }; | |
40 | 37 |
41 /** | 38 /** |
42 * @param {{ module:string, name: string }} details | 39 * @param {{ module:string, name: string }} details |
43 */ | 40 */ |
44 TestReporter.prototype.onTestDone_ = function(details) { | 41 TestReporter.prototype.onTestDone_ = function(details) { |
45 console.log('[---COMPLETED---] ' + details.module + '.' + details.name); | |
46 console.log('[===============]'); | |
47 if (this.failedAssertions_.length > 0) { | 42 if (this.failedAssertions_.length > 0) { |
48 this.errorMessage_ += ' ' + details.module + '.' + details.name + '\n'; | 43 this.errorMessage_ += ' ' + details.module + '.' + details.name + '\n'; |
49 this.errorMessage_ += this.failedAssertions_.map( | 44 this.errorMessage_ += this.failedAssertions_.map( |
50 function(assertion, index){ | 45 function(assertion, index){ |
51 return ' ' + (index + 1) + '. ' + assertion.message + '\n' + | 46 return ' ' + (index + 1) + '. ' + assertion.message + '\n' + |
52 ' ' + assertion.source; | 47 ' ' + assertion.source; |
53 }).join('\n'); | 48 }).join('\n') + '\n'; |
54 this.failedAssertions_ = []; | 49 this.failedAssertions_ = []; |
55 this.failedTestsCount_++; | 50 this.failedTestsCount_++; |
56 } | 51 } |
57 }; | 52 }; |
58 | 53 |
59 TestReporter.prototype.onAssertion_ = function(details) { | 54 TestReporter.prototype.onAssertion_ = function(details) { |
60 if (!details.result) { | 55 if (!details.result) { |
61 this.failedAssertions_.push(details); | 56 this.failedAssertions_.push(details); |
62 } | 57 } |
63 }; | 58 }; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 }; | 157 }; |
163 }; | 158 }; |
164 | 159 |
165 if (!QUnit.urlParams.disableTestTimeout) { | 160 if (!QUnit.urlParams.disableTestTimeout) { |
166 QUnit.test = function(name, expected, testCallback, async) { | 161 QUnit.test = function(name, expected, testCallback, async) { |
167 qunitTest(name, expected, BrowserTestHarness.test(testCallback), async); | 162 qunitTest(name, expected, BrowserTestHarness.test(testCallback), async); |
168 }; | 163 }; |
169 } | 164 } |
170 | 165 |
171 })(window.QUnit, window.domAutomationController, window); | 166 })(window.QUnit, window.domAutomationController, window); |
OLD | NEW |