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:io'; | 5 import 'dart:io'; |
6 | 6 |
7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
8 import 'package:unittest/src/backend/state.dart'; | 8 import 'package:unittest/src/backend/state.dart'; |
9 import 'package:unittest/src/runner/loader.dart'; | 9 import 'package:unittest/src/runner/loader.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 }); | 72 }); |
73 | 73 |
74 test("can load and run a failing test", () { | 74 test("can load and run a failing test", () { |
75 var liveTest = suite.tests[1].load(suite); | 75 var liveTest = suite.tests[1].load(suite); |
76 expectSingleFailure(liveTest); | 76 expectSingleFailure(liveTest); |
77 return liveTest.run().whenComplete(() => liveTest.close()); | 77 return liveTest.run().whenComplete(() => liveTest.close()); |
78 }); | 78 }); |
79 | 79 |
80 test("throws a nice error if the package root doesn't exist", () { | 80 test("throws a nice error if the package root doesn't exist", () { |
81 var loader = new Loader(); | 81 var loader = new Loader(); |
82 expect(() => loader.loadFile(p.join(_sandbox, 'a_test.dart')), | 82 expect(() { |
83 throwsA(isLoadException( | 83 try { |
84 "Directory ${p.join(_sandbox, 'packages')} does not exist."))); | 84 loader.loadFile(p.join(_sandbox, 'a_test.dart')); |
| 85 } finally { |
| 86 loader.close(); |
| 87 } |
| 88 }, throwsA(isLoadException( |
| 89 "Directory ${p.join(_sandbox, 'packages')} does not exist."))); |
85 }); | 90 }); |
86 }); | 91 }); |
87 | 92 |
88 group(".loadDir()", () { | 93 group(".loadDir()", () { |
89 test("ignores non-Dart files", () { | 94 test("ignores non-Dart files", () { |
90 new File(p.join(_sandbox, 'a_test.txt')).writeAsStringSync(_tests); | 95 new File(p.join(_sandbox, 'a_test.txt')).writeAsStringSync(_tests); |
91 expect(_loader.loadDir(_sandbox), completion(isEmpty)); | 96 expect(_loader.loadDir(_sandbox), completion(isEmpty)); |
92 }); | 97 }); |
93 | 98 |
94 test("ignores files in packages/ directories", () { | 99 test("ignores files in packages/ directories", () { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 133 |
129 test("can run tests in those suites", () { | 134 test("can run tests in those suites", () { |
130 var suite = suites.firstWhere((suite) => suite.name.contains("a_test")); | 135 var suite = suites.firstWhere((suite) => suite.name.contains("a_test")); |
131 var liveTest = suite.tests[1].load(suite); | 136 var liveTest = suite.tests[1].load(suite); |
132 expectSingleFailure(liveTest); | 137 expectSingleFailure(liveTest); |
133 return liveTest.run().whenComplete(() => liveTest.close()); | 138 return liveTest.run().whenComplete(() => liveTest.close()); |
134 }); | 139 }); |
135 }); | 140 }); |
136 }); | 141 }); |
137 } | 142 } |
OLD | NEW |