| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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 | 
|  | 3 // BSD-style license that can be found in the LICENSE file. | 
|  | 4 | 
|  | 5 import 'dart:async'; | 
|  | 6 import 'dart:io'; | 
|  | 7 | 
|  | 8 import 'package:scheduled_test/scheduled_test.dart'; | 
|  | 9 | 
|  | 10 import '../metatest.dart'; | 
|  | 11 import '../utils.dart'; | 
|  | 12 | 
|  | 13 void main() { | 
|  | 14   metaSetUp(() { | 
|  | 15     // TODO(nweiz): We used to only increase the timeout to 10s for the Windows | 
|  | 16     // bots, but the Linux and Mac bots have started taking upwards of 5s when | 
|  | 17     // running pumpEventQueue, so we're increasing the timeout across the board | 
|  | 18     // (see issue 9248). | 
|  | 19     currentSchedule.timeout = new Duration(seconds: 10); | 
|  | 20   }); | 
|  | 21 | 
|  | 22   expectTestsPass('setUp is run before each test', () { | 
|  | 23     var setUpRun = false; | 
|  | 24     setUp(() { | 
|  | 25       setUpRun = true; | 
|  | 26     }); | 
|  | 27 | 
|  | 28     test('test 1', () { | 
|  | 29       expect(setUpRun, isTrue); | 
|  | 30       setUpRun = false; | 
|  | 31     }); | 
|  | 32 | 
|  | 33     test('test 2', () { | 
|  | 34       expect(setUpRun, isTrue); | 
|  | 35       setUpRun = false; | 
|  | 36     }); | 
|  | 37   }); | 
|  | 38 | 
|  | 39   expectTestsPass('setUp can schedule events', () { | 
|  | 40     var setUpRun = false; | 
|  | 41     setUp(() { | 
|  | 42       schedule(() { | 
|  | 43         setUpRun = true; | 
|  | 44       }); | 
|  | 45       currentSchedule.onComplete.schedule(() { | 
|  | 46         setUpRun = false; | 
|  | 47       }); | 
|  | 48     }); | 
|  | 49 | 
|  | 50     test('test 1', () { | 
|  | 51       expect(setUpRun, isFalse); | 
|  | 52       schedule(() => expect(setUpRun, isTrue)); | 
|  | 53     }); | 
|  | 54 | 
|  | 55     test('test 2', () { | 
|  | 56       expect(setUpRun, isFalse); | 
|  | 57       schedule(() => expect(setUpRun, isTrue)); | 
|  | 58     }); | 
|  | 59   }); | 
|  | 60 | 
|  | 61   expectTestsFail('synchronous errors in setUp will cause tests to fail', () { | 
|  | 62     setUp(() => expect('foo', equals('bar'))); | 
|  | 63     test('test 1', () => expect('foo', equals('foo'))); | 
|  | 64     test('test 2', () => expect('foo', equals('foo'))); | 
|  | 65   }); | 
|  | 66 | 
|  | 67   expectTestsFail('scheduled errors in setUp will cause tests to fail', () { | 
|  | 68     setUp(() => schedule(() => expect('foo', equals('bar')))); | 
|  | 69     test('test 1', () => expect('foo', equals('foo'))); | 
|  | 70     test('test 2', () => expect('foo', equals('foo'))); | 
|  | 71   }); | 
|  | 72 | 
|  | 73   expectTestsPass('synchronous errors in setUp will cause onException to run', | 
|  | 74       () { | 
|  | 75     var onExceptionRun = false; | 
|  | 76     setUp(() { | 
|  | 77       currentSchedule.onException.schedule(() { | 
|  | 78         onExceptionRun = true; | 
|  | 79       }); | 
|  | 80 | 
|  | 81       if (!onExceptionRun) expect('foo', equals('bar')); | 
|  | 82     }); | 
|  | 83 | 
|  | 84     test('test 1', () => expect('foo', equals('foo'))); | 
|  | 85     test('test 2', () => expect(onExceptionRun, isTrue)); | 
|  | 86   }, passing: ['test 2']); | 
|  | 87 | 
|  | 88   expectTestsPass("setUp doesn't apply to child groups", () { | 
|  | 89     var setUpRun = false; | 
|  | 90     setUp(() { | 
|  | 91       setUpRun = true; | 
|  | 92       currentSchedule.onComplete.schedule(() { | 
|  | 93         setUpRun = false; | 
|  | 94       }); | 
|  | 95     }); | 
|  | 96 | 
|  | 97     test('outer', () { | 
|  | 98       expect(setUpRun, isTrue); | 
|  | 99     }); | 
|  | 100 | 
|  | 101     group('group', () { | 
|  | 102       test('inner', () { | 
|  | 103         expect(setUpRun, isFalse); | 
|  | 104       }); | 
|  | 105     }); | 
|  | 106   }); | 
|  | 107 | 
|  | 108   expectTestsPass("setUp doesn't apply to parent groups", () { | 
|  | 109     var setUpRun = false; | 
|  | 110     group('group', () { | 
|  | 111       setUp(() { | 
|  | 112         setUpRun = true; | 
|  | 113         currentSchedule.onComplete.schedule(() { | 
|  | 114           setUpRun = false; | 
|  | 115         }); | 
|  | 116       }); | 
|  | 117 | 
|  | 118       test('inner', () { | 
|  | 119         expect(setUpRun, isTrue); | 
|  | 120       }); | 
|  | 121     }); | 
|  | 122 | 
|  | 123     test('outer', () { | 
|  | 124       expect(setUpRun, isFalse); | 
|  | 125     }); | 
|  | 126   }); | 
|  | 127 | 
|  | 128   expectTestsPass("setUp doesn't apply to sibling groups", () { | 
|  | 129     var setUpRun = false; | 
|  | 130     group('group 1', () { | 
|  | 131       setUp(() { | 
|  | 132         setUpRun = true; | 
|  | 133         currentSchedule.onComplete.schedule(() { | 
|  | 134           setUpRun = false; | 
|  | 135         }); | 
|  | 136       }); | 
|  | 137 | 
|  | 138       test('test 1', () { | 
|  | 139         expect(setUpRun, isTrue); | 
|  | 140       }); | 
|  | 141     }); | 
|  | 142 | 
|  | 143     group('group 2', () { | 
|  | 144       test('test 2', () { | 
|  | 145         expect(setUpRun, isFalse); | 
|  | 146       }); | 
|  | 147     }); | 
|  | 148   }); | 
|  | 149 } | 
| OLD | NEW | 
|---|