Skip to content

Encourage splitting large test files in testing documentation#181880

Closed
crackedhandle wants to merge 6 commits into
flutter:mainfrom
crackedhandle:docs-split-large-test-files
Closed

Encourage splitting large test files in testing documentation#181880
crackedhandle wants to merge 6 commits into
flutter:mainfrom
crackedhandle:docs-split-large-test-files

Conversation

@crackedhandle

Copy link
Copy Markdown
Contributor

This PR updates the testing documentation to encourage contributors to split large test files into smaller, feature-focused files.

Smaller test files improve readability, navigation, maintainability, and reviewability.

Fixes #181819

@github-actions github-actions Bot added c: contributor-productivity Team-specific productivity, code health, technical debt. framework flutter/packages/flutter repository. See also f: labels. d: docs/ flutter/flutter/docs, for contributors labels Feb 3, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the testing documentation to encourage splitting large test files into smaller, more focused ones. The change adds a new section to Running-and-writing-tests.md that explains the benefits of this approach and mentions using dart_test.yaml for better organization. My feedback includes suggestions to add a link to the dart_test.yaml documentation and to expand the list of benefits to include faster test execution, both of which are supported by the repository's style guide.

Comment thread docs/contributing/testing/Running-and-writing-tests.md
Comment thread docs/contributing/testing/Running-and-writing-tests.md Outdated
- Reviewability for contributors
- Faster test execution (by enabling better parallelism)

When appropriate, configure [`dart_test.yaml`](https://github.com/dart-lang/test/blob/master/pkgs/test/doc/configuration.md) to manage test file patterns and improve organization across packages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line about dart_test.yaml has little to do with writing the actual tests?


### Organizing test files

Avoid creating overly large test files that contain many unrelated test cases.

@navaronbracke navaronbracke Feb 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it is true that sometimes tests end up in the wrong file (see the discoveries from the cross imports issue), most of the time the problem is just that there are a lot of closely related tests in a single file, rather than tests being in the wrong place.

@justinmc justinmc requested a review from loic-sharma February 3, 2026 23:33
@loic-sharma

loic-sharma commented Feb 5, 2026

Copy link
Copy Markdown
Member

Hello @crackedhandle, thanks for the patch! We recently had a Dash Forum - presented by @Piinks - on our style guide that covered the length of test files: flutter.dev/go/flutter-style-updates##heading=h.2annk22r4g84.

File length

Under Prefer more test files, avoid long test files, it specifies that test files should be kept around 200 lines long - lulz.
In packages/flutter alone, 528 test files (out of 942) are over 200 lines in length.
The average line length across all test files in package/flutter is 1,438 lines, so, we are clearly not following this.

  • Recommendation: Clarify language to make this guidance more about organization structure over specific line length e.g. solve “where should this test go”, naming conventions.
    • Alternative: We could adjust this rule to a more realistic line length, just remove it, or break up test files (which would be a lot of work, and potentiality for regressions).
    • Alternative: Remove the specific line number, update rule to better reflect empowerment to split up test files.
    • Alternative: Consider the use of groups to indicate test files should be split.
      • This may not be a solid heuristic, and we may not be able to take the time to go through test files just to break these up.

@Piinks will be updating Flutter's style guide soon with the guidance from that Dash Forum, which will likely also include similar guidance to split large test files by amending this section. I suspect that update will supersede this pull request and touch other parts of the style guide as well.

@crackedhandle

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback!

That makes sense — I agree that the dart_test.yaml reference may be out of scope here. I’ll remove that line.

Regarding the broader guidance, I understand that upcoming style guide updates may better address this. I’m happy to adjust or close this PR if that change supersedes this addition.

@crackedhandle crackedhandle force-pushed the docs-split-large-test-files branch from 159c8eb to 800f8cd Compare February 5, 2026 09:47
### Organizing test files

Avoid creating overly large test files that contain many unrelated test cases.
Instead, organize tests into smaller files grouped by feature, widget, or behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share some specific examples, such as naming convention?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for asking!

For example, instead of keeping everything in a single file like:

button_test.dart

that includes layout, semantics, and interaction tests, it could be split into:

  • button_layout_test.dart
  • button_semantics_test.dart
  • button_interaction_test.dart

Or grouping by behavior:

  • navigator_push_test.dart
  • navigator_pop_test.dart
  • navigator_transition_test.dart

The idea is to keep tests focused by feature or behavior so they’re easier to navigate, review, and maintain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Want to add it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yes, I can add these examples directly to the documentation to make the guidance clearer.

However, I’m currently managing some academic commitments, so it may take me a little time to incorporate the updates properly. I’ll work on refining the section and push the changes as soon as possible.

Appreciate the suggestion — it definitely improves the clarity of the guidelines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added naming convention examples to clarify the guidance. Please let me know if any further refinement is needed.

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@Piinks Piinks mentioned this pull request Feb 6, 2026
9 tasks
@crackedhandle

crackedhandle commented Feb 6, 2026

Copy link
Copy Markdown
Contributor Author

LGTM, thanks!

Thank you for the review and approval!

I’ve sent you a LinkedIn connection request (Divyansh Shah).
I’d be happy to connect and continue learning from your guidance.@Piinks

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 6, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 6, 2026
@auto-submit

auto-submit Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/181880, Failed to enqueue flutter/flutter/181880 with HTTP 400: GraphQL mutate failed.

@Piinks Piinks force-pushed the docs-split-large-test-files branch from 831d41f to 26d4c94 Compare February 6, 2026 19:32
@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 6, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 6, 2026
@auto-submit

auto-submit Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/181880, Failed to enqueue flutter/flutter/181880 with HTTP 400: GraphQL mutate failed.

@Piinks

Piinks commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Hey @crackedhandle we're debugging the submit issue. Can you push an empty commit to the PR?

@crackedhandle

Copy link
Copy Markdown
Contributor Author

Hey @crackedhandle we're debugging the submit issue. Can you push an empty commit to the PR?

Pushed an empty commit to retrigger CI. Please let me know if anything else is needed.

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 6, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 6, 2026
@auto-submit

auto-submit Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/181880, Failed to enqueue flutter/flutter/181880 with HTTP 400: GraphQL mutate failed.

@crackedhandle

Copy link
Copy Markdown
Contributor Author

I understand this may not be the appropriate place and time to ask, but I truly appreciate the guidance and discussions here.

If possible, I would be grateful to connect on LinkedIn, as I have a few questions and would love to learn more from your experience. Thank you for your time and support.@Piinks @loic-sharma

@jtmcdole

jtmcdole commented Feb 6, 2026

Copy link
Copy Markdown
Member

You're trying to merge to main - you must target master.

@Piinks

Piinks commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

You're trying to merge to main - you must target master.

Thanks @jtmcdole! Can you update the target to master @crackedhandle? Or open a new PR targeting master? We cannot merge to main.

@loic-sharma

Copy link
Copy Markdown
Member

If possible, I would be grateful to connect on LinkedIn, as I have a few questions and would love to learn more from your experience. Thank you for your time and support.@Piinks @loic-sharma

Thanks for the invite. I personally keep my LinkedIn network to my co-workers, but please feel free to reach out on Discord: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md

My Discord handle is loic_sharma, feel free to ping me directly if needed!

@crackedhandle crackedhandle force-pushed the docs-split-large-test-files branch from 6e66bc2 to dddce28 Compare February 7, 2026 10:05
crackedhandle and others added 2 commits February 7, 2026 15:46
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, bdfa942194aba63ff3afd5f87555d89cee757d83, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@crackedhandle

Copy link
Copy Markdown
Contributor Author

Thank you for the response — I completely understand

I appreciate you sharing the Discord details. I’ll join the Flutter Discord and reach out there if needed.

Also, I’ve created a new PR targeting master as suggested. Please let me know if everything looks correct.

Thanks again for your guidance and support!

@crackedhandle

Copy link
Copy Markdown
Contributor Author

@loic-sharma whats next anything needed?

@Piinks

Piinks commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Closing as replaced by #182051

@Piinks Piinks closed this Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. d: docs/ flutter/flutter/docs, for contributors framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants