-
Notifications
You must be signed in to change notification settings - Fork 1.7k
suite: add support for user-defined test filtering #1749
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
base: master
Are you sure you want to change the base?
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.
I see some value in the refactoring of Run
that moves the suite setup out of the loop. It would be worth submitting it as a separate cleanup PR.
However at this point I don't understand the use case. So I didn't take time to review the test suite.
The use case is not clear to me. I don't see why I would need this. So far this is 👎 for me. @renzoarreaza If you are serious about adding this feature, you'll have to convince us (Testify maintainers) better (first requirement), improve the provided documentation (2nd requirement). A runnable example would also be helpful as additional documentation (3rd requirement). |
Thanks for the feedback, I will take a look. I have some ideas to improve it (apart from your comments) and I will work on a clearer example of the use case. |
I have made some changes to the proposal. Motivation:The goal of this proposal is for the user to have a way to define a filter for which tests should or shouldn't run. |
## Summary Improve readability of suite.Run by moving the running of SetupSuite outside of the loop iterating over the (test) methods. This also allows for other simplifications further down in the code. ## Changes - Move SetupSuite to outside the loop - Don't run Setup/TeardownSuite if no tests are found (not new behaviour, but new check) - Remove variable to keep track of wether SetupSuite was executed or not ## Motivation This is a subset of the changes I made under PR #1749. It was suggested by @dolmen to open a separate PR for this part. ## Related issues N/A
@renzoarreaza I have just merged #1769 so a rebase would be welcome. |
98e231d
to
10cdced
Compare
I think it would be better to make sure that calling testing.T.Skip in the setup function stops that function and prevents the test and the teardown form being run too. Edit: Skip will stop both the rest of BeforeTest, and the test, but not the call to AfterTest. I raised #1781 |
Summary
Adds support for users to provide extra filtering on which tests to run.
Changes
A new Exported function was needed in the suite package to support this.
This function is the same as the existing Run function with an extra call to the skip function passed by the user.
I now let the
Run
function call this one.Another change was to move the running of the
SetupSuite
to outside the iteration of the (test) methods.If the skip function logs the skipped tests, this change makes sure all of these logs are together, at the top of the testrun, instead of having some skips, followed by the suite setup and more skips afterwards.
Motivation
The main motivation of this change is to allow for test registration. This allows tests to be skipped, as defined by the user, without repeatedly running the
SetupTest
/TeardownTest
repeatedly for skipped tests.Related
#1050 (issue) #1051 (PR)