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 @TestOn("vm") | 5 @TestOn("vm") |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 import 'package:test/src/backend/state.dart'; | 10 import 'package:test/src/backend/state.dart'; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return liveTest.run().whenComplete(() => liveTest.close()); | 81 return liveTest.run().whenComplete(() => liveTest.close()); |
82 }); | 82 }); |
83 | 83 |
84 test("can load and run a failing test", () { | 84 test("can load and run a failing test", () { |
85 var liveTest = suite.tests[1].load(suite); | 85 var liveTest = suite.tests[1].load(suite); |
86 expectSingleFailure(liveTest); | 86 expectSingleFailure(liveTest); |
87 return liveTest.run().whenComplete(() => liveTest.close()); | 87 return liveTest.run().whenComplete(() => liveTest.close()); |
88 }); | 88 }); |
89 }); | 89 }); |
90 | 90 |
91 test("throws a nice error if the package root doesn't exist", () { | |
92 var loader = new Loader([TestPlatform.chrome], root: _sandbox); | |
93 expect( | |
94 loader.loadFile(p.join(_sandbox, 'a_test.dart')).first | |
95 .whenComplete(loader.close), | |
96 throwsA(isLoadException( | |
97 "Directory ${p.join(_sandbox, 'packages')} does not exist."))); | |
98 }); | |
99 | |
100 test("loads a suite both in the browser and the VM", () { | 91 test("loads a suite both in the browser and the VM", () { |
101 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], | 92 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], |
102 root: _sandbox, | 93 root: _sandbox, |
103 packageRoot: p.join(packageDir, 'packages')); | 94 packageRoot: p.join(packageDir, 'packages')); |
104 var path = p.join(_sandbox, 'a_test.dart'); | 95 var path = p.join(_sandbox, 'a_test.dart'); |
105 return loader.loadFile(path).toList().then((suites) { | 96 return loader.loadFile(path).toList().then((suites) { |
106 expect(suites[0].platform, equals('VM')); | 97 expect(suites[0].platform, equals('VM')); |
107 expect(suites[0].path, equals(path)); | 98 expect(suites[0].path, equals(path)); |
108 expect(suites[1].platform, equals('Chrome')); | 99 expect(suites[1].platform, equals('Chrome')); |
109 expect(suites[1].path, equals(path)); | 100 expect(suites[1].path, equals(path)); |
110 | 101 |
111 for (var suite in suites) { | 102 for (var suite in suites) { |
112 expect(suite.tests, hasLength(3)); | 103 expect(suite.tests, hasLength(3)); |
113 expect(suite.tests[0].name, equals("success")); | 104 expect(suite.tests[0].name, equals("success")); |
114 expect(suite.tests[1].name, equals("failure")); | 105 expect(suite.tests[1].name, equals("failure")); |
115 expect(suite.tests[2].name, equals("error")); | 106 expect(suite.tests[2].name, equals("error")); |
116 } | 107 } |
117 }).whenComplete(loader.close); | 108 }).whenComplete(loader.close); |
118 }); | 109 }); |
119 } | 110 } |
OLD | NEW |