-
Notifications
You must be signed in to change notification settings - Fork 73
add support for setUpClass
and tearDownClass
#2164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 adds support for setUpClass
and tearDownClass
methods, which run once before and after all tests in a class, respectively. The implementation correctly uses a single instance for these class-level methods and ensures setUpClass
is only executed once. The accompanying tests effectively verify this new behavior. My feedback focuses on improving documentation and code style for the newly introduced methods to align with the repository's style guide, specifically regarding documenting public members and optimizing for readability.
8a1598a
to
d4d0d80
Compare
d4d0d80
to
5db9a48
Compare
5db9a48
to
4979e10
Compare
pkgs/test_reflective_loader/test/test_reflective_loader_test.dart
Outdated
Show resolved
Hide resolved
d2ede91
to
71dee67
Compare
ee94d1e
to
35a07f9
Compare
35a07f9
to
71317eb
Compare
786294f
to
1bc4e97
Compare
@scheglov i'm not sure what standard protocol is or if it matters, but since your reviews have significantly helped shape the code and its correctness i was thinking you should be credited as an author as well. i just don't know how to add you as one |
Don't worry about this, without you this change would not happen at all :-) |
About failing test, note that we have special case for other methods: https://github.com/dart-lang/sdk/blob/fcb1e9da9dd4a92c40b55644a7a535ad0ee48d28/pkg/linter/lib/src/rules/unreachable_from_main.dart#L129 |
PR HealthBreaking changes ✔️
This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with |
thanks for the direct link, i will update that code to consider the newly introduced names |
The PR dart-lang/tools#2164 introduces the ability to define `setUpClass` and `tearDownClass` static methods in test classes. Currently, such methods are linted as `unreachable_from_main` when they should not be linted just like other test methods
the |
PR HealthBreaking changes ✔️
This check can be disabled by tagging the PR with Changelog Entry ❗
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with |
This was fast! Unfortunately there are still lints reported, and I suspect that it will happen on older SDKs anyway. |
d545fbb
to
c638442
Compare
i have added the ignores and todos as you suggested |
i see the failed checks, i will work on resolving them |
cdd779a
to
74a6341
Compare
i made sure there's no warnings now (besides the todos) and updated the change log. i bumped the version to |
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
if a test class defines `setUpClass` it will be run before any tests are ever run. if it is asynchronous then no test runs until the future is completed `tearDownClass` is called once after all tests are run tests are updated to support and check for new behavior
74a6341
to
fcdc687
Compare
forgot to run dart format 😅 fixed that now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
no problem and thank you for being very responsive, it was a good learning experience for me i look forward to contributing more where i can |
Revisions updated by `dart tools/rev_sdk_deps.dart`. http (https://github.com/dart-lang/http/compare/d8e6929..d6dd5ec): d6dd5ec 2025-09-22 Willow Chargin [http2] Gracefully receive headers on canceled streams (dart-lang/http#1800) i18n (https://github.com/dart-lang/i18n/compare/a62bed2..09627d2): 09627d28 2025-09-19 Moritz Copybara import of the project: tools (https://github.com/dart-lang/tools/compare/042b03e..6c1eb21): 6c1eb214 2025-09-18 RohitSaily add support for `setUpClass` and `tearDownClass` (dart-lang/tools#2164) Change-Id: I892c69fbdabd650f91845abde6f21fe0866b9e12 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450940 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
if a test class defines
setUpClass
it will be run before any tests are ever run. if it is asynchronous then no test runs until the future is completedtearDownClass
is called once after all tests are runthe sameInstanceMirror
is used for the setup and for the tear-down, following how setup and tear-down is done for each unit testtests are updated to support and check for new behavior