| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; |
| 6 |
| 5 import 'package:test/src/backend/group.dart'; | 7 import 'package:test/src/backend/group.dart'; |
| 6 import 'package:test/src/backend/state.dart'; | 8 import 'package:test/src/backend/state.dart'; |
| 7 import 'package:test/src/runner/engine.dart'; | 9 import 'package:test/src/runner/engine.dart'; |
| 8 import 'package:test/src/runner/runner_suite.dart'; | 10 import 'package:test/src/runner/runner_suite.dart'; |
| 9 import 'package:test/src/runner/vm/environment.dart'; | 11 import 'package:test/src/runner/vm/environment.dart'; |
| 10 import 'package:test/test.dart'; | 12 import 'package:test/test.dart'; |
| 11 | 13 |
| 12 import '../utils.dart'; | 14 import '../utils.dart'; |
| 13 | 15 |
| 14 void main() { | 16 void main() { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 108 |
| 107 expect(engine.run(), completion(isFalse)); | 109 expect(engine.run(), completion(isFalse)); |
| 108 }); | 110 }); |
| 109 | 111 |
| 110 test(".run() may not be called more than once", () { | 112 test(".run() may not be called more than once", () { |
| 111 var engine = new Engine.withSuites([]); | 113 var engine = new Engine.withSuites([]); |
| 112 expect(engine.run(), completes); | 114 expect(engine.run(), completes); |
| 113 expect(engine.run, throwsStateError); | 115 expect(engine.run, throwsStateError); |
| 114 }); | 116 }); |
| 115 | 117 |
| 118 test("runs tearDown after a test times out", () { |
| 119 // Declare this here so the expect is in the context of this test, rather |
| 120 // than the inner test. |
| 121 var secondTestStarted = false; |
| 122 var firstTestFinished = false; |
| 123 var tearDownBody = expectAsync(() { |
| 124 print("running teardown"); |
| 125 expect(secondTestStarted, isFalse); |
| 126 expect(firstTestFinished, isFalse); |
| 127 }); |
| 128 |
| 129 var engine = declareEngine(() { |
| 130 // This ensures that the first test doesn't actually finish until the |
| 131 // second test runs. |
| 132 var firstTestCompleter = new Completer(); |
| 133 |
| 134 group("group", () { |
| 135 tearDown(tearDownBody); |
| 136 |
| 137 test("first test", () async { |
| 138 print("running first test"); |
| 139 await firstTestCompleter.future; |
| 140 firstTestFinished = true; |
| 141 }, timeout: new Timeout(Duration.ZERO)); |
| 142 }); |
| 143 |
| 144 test("second test", () { |
| 145 print("running second test"); |
| 146 secondTestStarted = true; |
| 147 firstTestCompleter.complete(); |
| 148 }); |
| 149 }); |
| 150 |
| 151 expect(engine.run(), completes); |
| 152 }); |
| 153 |
| 116 group("for a skipped test", () { | 154 group("for a skipped test", () { |
| 117 test("doesn't run the test's body", () async { | 155 test("doesn't run the test's body", () async { |
| 118 var bodyRun = false; | 156 var bodyRun = false; |
| 119 var engine = declareEngine(() { | 157 var engine = declareEngine(() { |
| 120 test("test", () => bodyRun = true, skip: true); | 158 test("test", () => bodyRun = true, skip: true); |
| 121 }); | 159 }); |
| 122 | 160 |
| 123 await engine.run(); | 161 await engine.run(); |
| 124 expect(bodyRun, isFalse); | 162 expect(bodyRun, isFalse); |
| 125 }); | 163 }); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 145 first = false; | 183 first = false; |
| 146 }, count: 2)); | 184 }, count: 2)); |
| 147 | 185 |
| 148 expect(liveTest.onComplete, completes); | 186 expect(liveTest.onComplete, completes); |
| 149 })); | 187 })); |
| 150 | 188 |
| 151 return engine.run(); | 189 return engine.run(); |
| 152 }); | 190 }); |
| 153 }); | 191 }); |
| 154 } | 192 } |
| OLD | NEW |