Skip to content

flutter test can't run multiple integration test files on desktop #135673

Closed

Description

@stuartmorgan-g

(This may well apply to the other desktop platform as well; I haven't tried them, but a lot of the flutter code to run desktop apps is similar across platforms.)

STR:

  1. Check out flutter/packages and cd to packages/video_player/video_player/example
  2. Run flutter test -d macos integration_test/controller_swap_test.dart
  3. Run flutter test -d macos integration_test/video_player_test.dart
  4. Run flutter test -d macos integration_test/

Steps 2 and 3 work fine. Step 4 however, which should have essentially the same effect as 2+3 (those are the two test files in that directory), runs one set of tests—the app visibly launches, then quits—then when it tries to run the second launches the app but doesn't run tests, and instead logs:

  TestDeviceException(Unable to start the app on the device.)
  package:flutter_tools/src/test/integration_test_device.dart 63:7  IntegrationTestTestDevice.start
  
  Bad state: Cannot add new events after calling close
  dart:async/broadcast_stream_controller.dart 243:24  _BroadcastStreamController.add
  dart:async/zone.dart 1407:47                        _rootRunUnary
  dart:async/zone.dart 1308:19                        _CustomZone.runUnary
  dart:async/zone.dart 1217:7                         _CustomZone.runUnaryGuarded
  dart:async/stream_impl.dart 339:11                  _BufferingStreamSubscription._sendData
  dart:async/stream_impl.dart 271:7                   _BufferingStreamSubscription._add
  dart:async/stream_controller.dart 784:19            _SyncStreamControllerDispatch._sendData
  dart:async/stream_controller.dart 658:7             _StreamController._add
  dart:async/stream_controller.dart 606:5             _StreamController.add
  dart:io-patch/socket_patch.dart 2447:41             _Socket._onData
  dart:async/zone.dart 1415:13                        _rootRunUnary
  dart:async/zone.dart 1308:19                        _CustomZone.runUnary
  dart:async/zone.dart 1217:7                         _CustomZone.runUnaryGuarded
  dart:async/stream_impl.dart 339:11                  _BufferingStreamSubscription._sendData
  dart:async/stream_impl.dart 271:7                   _BufferingStreamSubscription._add
  dart:async/stream_controller.dart 784:19            _SyncStreamControllerDispatch._sendData
  dart:async/stream_controller.dart 658:7             _StreamController._add
  dart:async/stream_controller.dart 606:5             _StreamController.add
  dart:io-patch/socket_patch.dart 1936:33             new _RawSocket.<fn>
  dart:io-patch/socket_patch.dart 1379:14             _NativeSocket.issueReadEvent.issue
  dart:async/schedule_microtask.dart 40:21            _microtaskLoop
  dart:async/schedule_microtask.dart 49:5             _startMicrotaskLoop
  dart:isolate-patch/isolate_patch.dart 118:13        _runPendingImmediateCallback
  dart:isolate-patch/isolate_patch.dart 185:5         _RawReceivePort._handleMessage

and then sits there doing nothing with the app still open.

It looks like something about the flutter test logic for desktop is trying to re-use a stream when it does subsequent launches.

Activity

  1. added
    a: tests"flutter test", flutter_test, or one of our tests
    toolAffects the "flutter" command-line tool. See also t: labels.
    platform-macosBuilding on or for macOS specifically
    on Sep 28, 2023
  2. changed the title [-]`flutter test` can't run multiple integration tests on macOS[/-] [+]`flutter test` can't run multiple integration test files on macOS[/+] on Sep 28, 2023
  3. added
    P2Important issues not at the top of the work list
    fyi-toolFor the attention of Flutter Tool team
    on Sep 28, 2023
  4. added
    team-toolOwned by Flutter Tool team
    and removed on Oct 2, 2023
  5. flutter-triage-bot commented on Oct 2, 2023

    @flutter-triage-bot

    The fyi-tool label is redundant with the team-tool label.

  6. 11 remaining items

  7. jigar-f commented on Oct 28, 2024

    @jigar-f
  8. biendltb commented on Apr 14, 2025

    @biendltb

    (This may well apply to the other desktop platform as well; I haven't tried them, but a lot of the flutter code to run desktop apps is similar across platforms.)

    This does indeed also happen on Linux (so almost certainly happens on Windows as well).

    I could confirm that it still happens in Linux. One workaround is to change the main() in all the integration test file in to separate functions and create a runner file which runs all of those fuctions. I don't like this idea either since the we sometimes need separation between tests.

  9. added
    tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.
    on Jul 11, 2025
  10. welcomeworld commented on Mar 28, 2026

    @welcomeworld
  11. bkonyi commented on Aug 27, 2026

    @bkonyi
    Contributor

    Fixed in #189192 (commit 3a1a745).

  12. github-actions commented on Sep 10, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopa: tests"flutter test", flutter_test, or one of our testsplatform-linuxBuilding on or for Linux specificallyplatform-macosBuilding on or for macOS specificallyteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions