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

Side by Side Diff: lib/src/live_test.dart

Issue 877553009: Add some basic interfaces that will be used for the test runner. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes Created 5 years, 10 months 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
« no previous file with comments | « no previous file | lib/src/live_test_controller.dart » ('j') | 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) 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library unittest.live_test;
6
7 import 'dart:async';
8
9 import 'state.dart';
10 import 'suite.dart';
11 import 'test.dart';
12
13 /// A runnable instance of a test.
14 ///
15 /// This is distinct from [Test] in order to keep [Test]. Running a test
16 /// requires state, and [LiveTest] provides a view of the state of the test as
17 /// it runs.
18 ///
19 /// If the state changes, [state] will be updated before [onStateChange] fires.
20 /// Likewise, if an error is caught, it will be added to [errors] before being
21 /// emitted via [onError]. If an error causes a state change, [onStateChange]
22 /// will fire before [onError]. If an error or other state change causes the
23 /// test to complete, [onComplete] will complete after [onStateChange] and
24 /// [onError] fire.
25 abstract class LiveTest {
26 /// The suite within which this test is being run.
27 Suite get suite;
28
29 /// The running test.
30 Test get test;
31
32 /// The current state of the running test.
33 ///
34 /// This starts as [Status.pending] and [Result.success]. It will be updated
35 /// before [onStateChange] fires.
36 ///
37 /// Note that even if this is marked [Status.complete], the test may still be
38 /// running code asynchronously. A test is considered complete either once it
39 /// hits its first error or when all [expectAsync] callbacks have been called
40 /// and any returned [Future] has completed, but it's possible for further
41 /// processing to happen, which may cause further errors. It's even possible
42 /// for a test that was marked [Status.complete] and [Result.success] to be
43 /// marked as [Result.error] later.
44 State get state;
45
46 /// Returns whether this test has completed.
47 ///
48 /// This is equivalent to [state.status] being [Status.complete].
49 ///
50 /// Note that even if this returns `true`, the test may still be
51 /// running code asynchronously. A test is considered complete either once it
52 /// hits its first error or when all [expectAsync] callbacks have been called
53 /// and any returned [Future] has completed, but it's possible for further
54 /// processing to happen, which may cause further errors.
55 bool get isComplete => state.status == Status.complete;
56
57 // A stream that emits a new [State] whenever [state] changes.
58 //
59 // This will only ever emit a [State] if it's different than the previous
60 // [state]. It will emit an event after [state] has been updated. Note that
61 // since this is an asynchronous stream, it's possible for [state] not to
62 // match the [State] that it emits within the [Stream.listen] callback.
63 Stream<State> get onStateChange;
64
65 /// An unmodifiable list of all errors that have been caught while running
66 /// this test.
67 ///
68 /// This will be updated before [onError] fires. These errors are not
69 /// guaranteed to have the same types as when they were thrown; for example,
70 /// they may need to be serialized across isolate boundaries. The stack traces
71 /// will be [Chain]s.
72 List<AsyncError> get errors;
73
74 /// A stream that emits a new [AsyncError] whenever an error is caught.
75 ///
76 /// This will be emit an event after [errors] is updated. These errors are not
77 /// guaranteed to have the same types as when they were thrown; for example,
78 /// they may need to be serialized across isolate boundaries. The stack traces
79 /// will be [Chain]s.
80 Stream<AsyncError> get onError;
81
82 /// A [Future] that completes once the test is complete.
83 ///
84 /// This will complete after [onStateChange] has fired, and after [onError]
85 /// has fired if the test completes because of an error. It's the same as the
86 /// [Future] returned by [run].
87 ///
88 /// Note that even once this completes, the test may still be running code
89 /// asynchronously. A test is considered complete either once it hits its
90 /// first error or when all [expectAsync] callbacks have been called and any
91 /// returned [Future] has completed, but it's possible for further processing
92 /// to happen, which may cause further errors.
93 Future get onComplete;
94
95 /// Signals that this test should start running as soon as possible.
96 ///
97 /// A test may not start running immediately for various reasons specific to
98 /// the means by which it's defined. Until it starts running, [state] will
99 /// continue to be marked [Status.pending].
100 ///
101 /// This returns the same [Future] as [onComplete]. It may not be called more
102 /// than once.
103 Future run();
104 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/live_test_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698