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

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: 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/pubspec.yaml ('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) {
kevmoo 2014/11/11 21:27:53 Please use follow the convention of other unittest
wibling 2014/11/12 10:33:46 I am not sure how I should do that? I am currentl
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() {
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) {
33 if (error is! StateError)
34 throw error;
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/pubspec.yaml ('K') | « pkg/unittest/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698