Skip to content

flutter test --coverage and flutter test --watch #4719

Closed as not planned
Closed as not planned

Description

@Hixie
  • flutter test --coverage should write:
    • two identical files, a base file and a coverage file,
    • plus a file that lists the last modification times of all the test files.
  • flutter test --watch should watch the file system of the current package.
    • If a file under lib/ changes, it should rerun all the tests and create a new base file and timestamp file.
    • If a file under 'test/' changes, it should rerun all the tests with timestamps that indicate the file changed since the base file was written.
    • after flutter test --watch runs some tests, it should merge the new coverage with the base file and overwrite the coverage file.
  • We should document the caveats here:
    • Tests that have expectations or that depend on non-test files won't be run when those files change.
    • Reducing coverage won't be noticed.
    • Coverage is per-line and hitting any expression on the line counts as covering the line.

Activity

  1. modified the milestone: on Sep 12, 2016
  2. modified the milestones: , on Jan 31, 2017
  3. modified the milestones: , on Jan 17, 2018
  4. Hixie commented on Sep 12, 2018

    @Hixie
    ContributorAuthor

    cc @aam

  5. modified the milestones: , on Sep 12, 2018
  6. 16 remaining items

  7. removed this from the milestone on Jul 7, 2020
  8. modified the milestone: on Jul 22, 2020
  9. removed this from the milestone on Aug 17, 2020
  10. szotp commented on Aug 22, 2020

    @szotp

    It looks like it won't be implemented anytime soon so I'm considering a workaround - since flutter already supports hot reload, I could add my tests as a package directly to the app as dev dependency, and re run tests on each hot reload.

    EDIT: This actually works pretty well, I've made a package for other people to try it: https://github.com/szotp/hottie/

  11. HerrNiklasRaab commented on Oct 28, 2020

    @HerrNiklasRaab
  12. danielgomezrico commented on Dec 10, 2020

    @danielgomezrico
    Contributor

    Is there any possibility that flutter test --watch run only the tests related to the file that changed?
    I loved the behavior of https://github.com/guard/guard-test.

  13. YazeedAlKhalaf commented on Jul 20, 2022

    @YazeedAlKhalaf
    Contributor

    can we possible have something similar to how bazel does caching of tests.

    if you're familiar with running a project that has bazel, you will notice that only tests of files changed are run after the first run which runs everything.

    if we integrate this into the watch flag it would make development so much faster.

  14. matanlurey commented on Jun 27, 2025

    @matanlurey
    Contributor

    This feature is not planned, of course it's great that the community is able to write custom packages.

  15. github-actions commented on Jul 11, 2025

    @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.

  16. locked as resolved and limited conversation to collaborators on Jul 11, 2025
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

    P3Issues that are less important to the Flutter projecta: tests"flutter test", flutter_test, or one of our testsc: new featureNothing broken; request for a new capabilityteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.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