LCOV - code coverage report
Current view: top level - test_api-0.4.8/lib/src/scaffolding - utils.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 11 0.0 %
Date: 2021-11-28 14:37:50 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2021, 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 'dart:async';
       6             : 
       7             : import '../backend/invoker.dart';
       8             : 
       9             : /// Returns a [Future] that completes after the [event loop][] has run the given
      10             : /// number of [times] (20 by default).
      11             : ///
      12             : /// [event loop]: https://medium.com/dartlang/dart-asynchronous-programming-isolates-and-event-loops-bffc3e296a6a
      13             : ///
      14             : /// Awaiting this approximates waiting until all asynchronous work (other than
      15             : /// work that's waiting for external resources) completes.
      16           0 : Future pumpEventQueue({int times = 20}) {
      17           0 :   if (times == 0) return Future.value();
      18             :   // Use the event loop to allow the microtask queue to finish.
      19           0 :   return Future(() => pumpEventQueue(times: times - 1));
      20             : }
      21             : 
      22             : /// Registers an exception that was caught for the current test.
      23           0 : void registerException(Object error,
      24             :     [StackTrace stackTrace = StackTrace.empty]) {
      25             :   // This will usually forward directly to [Invoker.current.handleError], but
      26             :   // going through the zone API allows other zones to consistently see errors.
      27           0 :   Zone.current.handleUncaughtError(error, stackTrace);
      28             : }
      29             : 
      30             : /// Prints [message] if and when the current test fails.
      31             : ///
      32             : /// This is intended for test infrastructure to provide debugging information
      33             : /// without cluttering the output for successful tests. Note that unlike
      34             : /// [print], each individual message passed to [printOnFailure] will be
      35             : /// separated by a blank line.
      36           0 : void printOnFailure(String message) {
      37           0 :   _currentInvoker.printOnFailure(message);
      38             : }
      39             : 
      40             : /// Marks the current test as skipped.
      41             : ///
      42             : /// A skipped test may still fail if any exception is thrown, including uncaught
      43             : /// asynchronous errors. If the entire test should be skipped `return` from the
      44             : /// test body after marking it as skipped.
      45           0 : void markTestSkipped(String message) => _currentInvoker..skip(message);
      46             : 
      47           0 : Invoker get _currentInvoker =>
      48           0 :     Invoker.current ??
      49           0 :     (throw StateError(
      50             :         'There is no current invoker. Please make sure that you are making the '
      51             :         'call inside a test zone.'));

Generated by: LCOV version 1.14