Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: pkg/unittest/test/with_test_environment_test.dart

Issue 709903004: Enhance the Dart unittest library to support multiple invocations in the same application run. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: more review feedback Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« pkg/unittest/lib/unittest.dart ('K') | « pkg/unittest/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 library unittest.with_test_environment_test;
6
7 import 'package:unittest/unittest.dart';
8
9 void runUnittests(Function callback) {
10 unittestConfiguration = new SimpleConfiguration();
11 callback();
12 }
13
14 void runTests() {
15 test('test', () => expect(2 + 3, equals(5)));
16 }
17
18 void runTests1() {
19 test('test1', () => expect(4 + 3, equals(7)));
20 }
21
22 // Test that we can run two different sets of tests in the same run using the
23 // withTestEnvironment method.
24 void main() {
nweiz 2014/11/13 19:34:28 Why doesn't this use metatest to isolate its test
wibling 2014/11/14 10:09:49 I am not sure what the benefit of metatests would
nweiz 2014/11/17 23:02:54 metatest allows you to create isolated test run wi
wibling 2014/11/18 10:16:49 I did look at the other tests and also at the meta
nweiz 2014/11/19 21:40:39 Oh, I see, that's a good point. It's probably poss
25 // First check that we cannot call runUnittests twice in a row without it
26 // throwing a StateError due to the unittestConfiguration being set globally
27 // in the first call.
28 try {
29 runUnittests(runTests);
30 runUnittests(runTests1);
31 throw 'Expected this to be unreachable since 2nd run above should throw';
32 } catch(error) {
nweiz 2014/11/13 19:34:28 Add a space after "catch". Also, if you write "on
wibling 2014/11/14 10:09:49 Done.
33 if (error is! StateError)
34 throw error;
nweiz 2014/11/13 19:34:28 If you're using a bracketless if, you must put the
wibling 2014/11/14 10:09:49 Done.
35 // expected, silently ignore.
36 }
37
38 // Second test that we can run both when encapsulating in their own private
39 // test environment.
40 withTestEnvironment(() => runUnittests(runTests));
41 withTestEnvironment(() => runUnittests(runTests1));
42
43 // Third test that we can run with two nested test environments.
44 withTestEnvironment(() {
45 runUnittests(runTests);
46 withTestEnvironment(() {
47 runUnittests(runTests1);
48 });
49 });
50 }
OLDNEW
« pkg/unittest/lib/unittest.dart ('K') | « pkg/unittest/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698