Line data Source code
1 : // Copyright (c) 2016, 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 : import 'package:collection/collection.dart'; 6 : 7 : import 'package:test_api/src/backend/live_test.dart'; // ignore: implementation_imports 8 : 9 : import 'runner_suite.dart'; 10 : 11 : /// A view of the execution of a test suite. 12 : /// 13 : /// This is distinct from [Suite] because it represents the progress of running 14 : /// a suite rather than the suite's contents. It provides events and collections 15 : /// that give the caller a view into the suite's current state. 16 : abstract class LiveSuite { 17 : /// The suite that's being run. 18 : RunnerSuite get suite; 19 : 20 : /// A [Future] that completes once the suite is complete. 21 : /// 22 : /// Note that even once this completes, the suite may still be running code 23 : /// asynchronously. A suite is considered complete once all of its tests are 24 : /// complete, but it's possible for a test to continue running even after it's 25 : /// been marked complete—see [LiveTest.isComplete] for details. 26 : /// 27 : /// The [onClose] future can be used to determine when the suite and its tests 28 : /// are guaranteed to emit no more events. 29 : Future get onComplete; 30 : 31 : /// Whether the suite has been closed. 32 : /// 33 : /// If this is `true`, no code is running for the suite or any of its tests. 34 : /// At this point, the caller can be sure that the suites' tests are all in 35 : /// fixed states that will not change in the future. 36 : bool get isClosed; 37 : 38 : /// A [Future] that completes when the suite has been closed. 39 : /// 40 : /// Once this completes, no code is running for the suite or any of its tests. 41 : /// At this point, the caller can be sure that the suites' tests are all in 42 : /// fixed states that will not change in the future. 43 : Future get onClose; 44 : 45 : /// All the currently-known tests in this suite that have run or are running. 46 : /// 47 : /// This is guaranteed to contain the same tests as the union of [passed], 48 : /// [skipped], [failed], and [active]. 49 0 : Set<LiveTest> get liveTests => UnionSet.from([ 50 0 : passed, 51 0 : skipped, 52 0 : failed, 53 0 : if (active != null) {active!} 54 : ]); 55 : 56 : /// A stream that emits each [LiveTest] in this suite as it's about to start 57 : /// running. 58 : /// 59 : /// This is guaranteed to fire before [LiveTest.onStateChange] first fires. It 60 : /// will close once all tests the user has selected are run. 61 : Stream<LiveTest> get onTestStarted; 62 : 63 : /// The set of tests in this suite that have completed and been marked as 64 : /// passing. 65 : Set<LiveTest> get passed; 66 : 67 : /// The set of tests in this suite that have completed and been marked as 68 : /// skipped. 69 : Set<LiveTest> get skipped; 70 : 71 : /// The set of tests in this suite that have completed and been marked as 72 : /// failing or error. 73 : Set<LiveTest> get failed; 74 : 75 : /// The currently running test in this suite, or `null` if no test is running. 76 : LiveTest? get active; 77 : }