| OLD | NEW | 
|---|
| (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 test.backend.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 stream that emits lines printed by the test. | 
|  | 83   Stream<String> onPrint; | 
|  | 84 | 
|  | 85   /// A [Future] that completes once the test is complete. | 
|  | 86   /// | 
|  | 87   /// This will complete after [onStateChange] has fired, and after [onError] | 
|  | 88   /// has fired if the test completes because of an error. It's the same as the | 
|  | 89   /// [Future] returned by [run]. | 
|  | 90   /// | 
|  | 91   /// Note that even once this completes, the test may still be running code | 
|  | 92   /// asynchronously. A test is considered complete either once it hits its | 
|  | 93   /// first error or when all [expectAsync] callbacks have been called and any | 
|  | 94   /// returned [Future] has completed, but it's possible for further processing | 
|  | 95   /// to happen, which may cause further errors. | 
|  | 96   Future get onComplete; | 
|  | 97 | 
|  | 98   /// Signals that this test should start running as soon as possible. | 
|  | 99   /// | 
|  | 100   /// A test may not start running immediately for various reasons specific to | 
|  | 101   /// the means by which it's defined. Until it starts running, [state] will | 
|  | 102   /// continue to be marked [Status.pending]. | 
|  | 103   /// | 
|  | 104   /// This returns the same [Future] as [onComplete]. It may not be called more | 
|  | 105   /// than once. | 
|  | 106   Future run(); | 
|  | 107 | 
|  | 108   /// Signals that this test should stop emitting events and release any | 
|  | 109   /// resources it may have allocated. | 
|  | 110   /// | 
|  | 111   /// Once [close] is called, [onComplete] will complete if it hasn't already | 
|  | 112   /// and [onStateChange] and [onError] will close immediately. This means that, | 
|  | 113   /// if the test was running at the time [close] is called, it will never emit | 
|  | 114   /// a [Status.complete] state-change event. Once a test is closed, [expect] | 
|  | 115   /// and [expectAsync] will throw a [ClosedException] to help the test | 
|  | 116   /// terminate as quickly as possible. | 
|  | 117   /// | 
|  | 118   /// This doesn't automatically happen after the test completes because there | 
|  | 119   /// may be more asynchronous work going on in the background that could | 
|  | 120   /// produce new errors. | 
|  | 121   /// | 
|  | 122   /// Returns a [Future] that completes once all resources are released *and* | 
|  | 123   /// the test has completed. This allows the caller to wait until the test's | 
|  | 124   /// tear-down logic has run. | 
|  | 125   Future close(); | 
|  | 126 } | 
| OLD | NEW | 
|---|