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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 var suites = await _loader.loadFile(p.join(_sandbox, 'a_test.dart')) | 53 var suites = await _loader.loadFile(p.join(_sandbox, 'a_test.dart')) |
54 .toList(); | 54 .toList(); |
55 | 55 |
56 expect(suites, hasLength(1)); | 56 expect(suites, hasLength(1)); |
57 var loadSuite = suites.first; | 57 var loadSuite = suites.first; |
58 suite = await loadSuite.getSuite(); | 58 suite = await loadSuite.getSuite(); |
59 }); | 59 }); |
60 | 60 |
61 test("returns a suite with the file path and platform", () { | 61 test("returns a suite with the file path and platform", () { |
62 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart'))); | 62 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart'))); |
63 expect(suite.platform, equals('Chrome')); | 63 expect(suite.platform, equals(TestPlatform.chrome)); |
64 }); | 64 }); |
65 | 65 |
66 test("returns tests with the correct names", () { | 66 test("returns tests with the correct names", () { |
67 expect(suite.tests, hasLength(3)); | 67 expect(suite.tests, hasLength(3)); |
68 expect(suite.tests[0].name, equals("success")); | 68 expect(suite.tests[0].name, equals("success")); |
69 expect(suite.tests[1].name, equals("failure")); | 69 expect(suite.tests[1].name, equals("failure")); |
70 expect(suite.tests[2].name, equals("error")); | 70 expect(suite.tests[2].name, equals("error")); |
71 }); | 71 }); |
72 | 72 |
73 test("can load and run a successful test", () { | 73 test("can load and run a successful test", () { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 test("loads a suite both in the browser and the VM", () async { | 125 test("loads a suite both in the browser and the VM", () async { |
126 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], | 126 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], |
127 root: _sandbox, | 127 root: _sandbox, |
128 packageRoot: p.join(packageDir, 'packages')); | 128 packageRoot: p.join(packageDir, 'packages')); |
129 var path = p.join(_sandbox, 'a_test.dart'); | 129 var path = p.join(_sandbox, 'a_test.dart'); |
130 | 130 |
131 try { | 131 try { |
132 var suites = await loader.loadFile(path) | 132 var suites = await loader.loadFile(path) |
133 .asyncMap((loadSuite) => loadSuite.getSuite()).toList(); | 133 .asyncMap((loadSuite) => loadSuite.getSuite()).toList(); |
134 expect(suites[0].platform, equals('VM')); | 134 expect(suites[0].platform, equals(TestPlatform.vm)); |
135 expect(suites[0].path, equals(path)); | 135 expect(suites[0].path, equals(path)); |
136 expect(suites[1].platform, equals('Chrome')); | 136 expect(suites[1].platform, equals(TestPlatform.chrome)); |
137 expect(suites[1].path, equals(path)); | 137 expect(suites[1].path, equals(path)); |
138 | 138 |
139 for (var suite in suites) { | 139 for (var suite in suites) { |
140 expect(suite.tests, hasLength(3)); | 140 expect(suite.tests, hasLength(3)); |
141 expect(suite.tests[0].name, equals("success")); | 141 expect(suite.tests[0].name, equals("success")); |
142 expect(suite.tests[1].name, equals("failure")); | 142 expect(suite.tests[1].name, equals("failure")); |
143 expect(suite.tests[2].name, equals("error")); | 143 expect(suite.tests[2].name, equals("error")); |
144 } | 144 } |
145 } finally { | 145 } finally { |
146 await loader.close(); | 146 await loader.close(); |
(...skipping 10 matching lines...) Expand all Loading... |
157 .toList(); | 157 .toList(); |
158 expect(suites, hasLength(1)); | 158 expect(suites, hasLength(1)); |
159 var loadSuite = suites.first; | 159 var loadSuite = suites.first; |
160 | 160 |
161 var liveTest = await loadSuite.tests.single.load(loadSuite); | 161 var liveTest = await loadSuite.tests.single.load(loadSuite); |
162 expect(liveTest.onPrint.first, completion(equals("print within test"))); | 162 expect(liveTest.onPrint.first, completion(equals("print within test"))); |
163 await liveTest.run(); | 163 await liveTest.run(); |
164 expectTestPassed(liveTest); | 164 expectTestPassed(liveTest); |
165 }); | 165 }); |
166 } | 166 } |
OLD | NEW |