Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library unittestTest; | 5 library unittest.async_setup_teardown; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:isolate'; | |
| 9 | 8 |
| 10 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 11 | 10 |
| 12 part 'utils.dart'; | 11 import 'package:metatest/metatest.dart'; |
| 13 | 12 |
| 14 var testName = 'async setup teardown test'; | 13 void main() => initTests(_test); |
| 15 | 14 |
| 16 var testFunction = (_) { | 15 void _test(message) { |
| 17 group('good setup/good teardown', () { | 16 initMetatest(message); |
| 17 | |
| 18 expectSingleTest('good setup/good teardown', 'pass', '', () { | |
|
nweiz
2014/09/10 21:04:43
This interface is really hard to read. Why is the
kevmoo
2014/09/17 21:16:29
I eliminated expectSingleTest. Fewer methods == be
| |
| 18 setUp(() { | 19 setUp(() { |
| 19 return new Future.value(0); | 20 return new Future.value(0); |
| 20 }); | 21 }); |
| 21 tearDown(() { | 22 tearDown(() { |
| 22 return new Future.value(0); | 23 return new Future.value(0); |
| 23 }); | 24 }); |
| 24 test('foo1', () {}); | 25 test('foo1', () {}); |
| 25 }); | 26 }); |
| 26 group('good setup/bad teardown', () { | 27 |
| 28 expectSingleTest( | |
| 29 'good setup/bad teardown', | |
| 30 'error', | |
| 31 'Teardown failed: Caught Failed to complete tearDown', | |
| 32 () { | |
| 27 setUp(() { | 33 setUp(() { |
| 28 return new Future.value(0); | 34 return new Future.value(0); |
| 29 }); | 35 }); |
| 30 tearDown(() { | 36 tearDown(() { |
| 31 return new Future.error("Failed to complete tearDown"); | 37 return new Future.error("Failed to complete tearDown"); |
| 32 }); | 38 }); |
| 33 test('foo2', () {}); | 39 test('foo2', () {}); |
| 34 }); | 40 }); |
| 35 group('bad setup/good teardown', () { | 41 |
| 42 expectSingleTest( | |
| 43 'bad setup/good teardown', | |
| 44 'error', | |
| 45 'Setup failed: Caught Failed to complete setUp', | |
| 46 () { | |
| 36 setUp(() { | 47 setUp(() { |
| 37 return new Future.error("Failed to complete setUp"); | 48 return new Future.error("Failed to complete setUp"); |
| 38 }); | 49 }); |
| 39 tearDown(() { | 50 tearDown(() { |
| 40 return new Future.value(0); | 51 return new Future.value(0); |
| 41 }); | 52 }); |
| 42 test('foo3', () {}); | 53 test('foo3', () {}); |
| 43 }); | 54 }); |
| 44 group('bad setup/bad teardown', () { | 55 |
| 56 expectSingleTest( | |
| 57 'bad setup/bad teardown', | |
| 58 'error', | |
| 59 'Setup failed: Caught Failed to complete setUp', | |
| 60 () { | |
| 45 setUp(() { | 61 setUp(() { |
| 46 return new Future.error("Failed to complete setUp"); | 62 return new Future.error("Failed to complete setUp"); |
| 47 }); | 63 }); |
| 48 tearDown(() { | 64 tearDown(() { |
| 49 return new Future.error("Failed to complete tearDown"); | 65 return new Future.error("Failed to complete tearDown"); |
| 50 }); | 66 }); |
| 51 test('foo4', () {}); | 67 test('foo4', () {}); |
| 52 }); | 68 }); |
| 53 // The next test is just to make sure we make steady progress | 69 } |
| 54 // through the tests. | |
| 55 test('post groups', () {}); | |
| 56 }; | |
| 57 | |
| 58 final expected = buildStatusString(2, 0, 3, | |
| 59 'good setup/good teardown foo1::' | |
| 60 'good setup/bad teardown foo2:' | |
| 61 'Teardown failed: Caught Failed to complete tearDown:' | |
| 62 'bad setup/good teardown foo3:' | |
| 63 'Setup failed: Caught Failed to complete setUp:' | |
| 64 'bad setup/bad teardown foo4:' | |
| 65 'Setup failed: Caught Failed to complete setUp:' | |
| 66 'post groups'); | |
| OLD | NEW |