Skip to content

Conversation

renzoarreaza
Copy link
Contributor

@renzoarreaza renzoarreaza commented May 24, 2025

Summary

This PR makes 2 changes to the suite package.

  1. Adds a repeat argument -testify.r to run tests multiple times without rerunning Setup/TeardownSuite
  2. Adds support for users to provide extra filtering

Changes & Motivation

Change 1:
The first change allows tests to be repeated multiple times. Using go test's -count option results in the Setup/TeardownSuite also running multiple times. There are cases where this is not desired since the Setup/TeardownSuite may take a long time.

Change 2:
The second change allows users of the suite package to "extend" it with their own skip function.
The tests I added show overly simplified implementation, but this allows you to have test registration, and apply this during the collection phase of the testrun.
Additionally, the running of the SetupSuite was moved to outside the loop.
This is to avoid it running unnecessarily when you try to run a specific test that is filtered out but others aren't.
e.g:
go test MySuite/MyTest
MyTest is skipped by the skip function, but the iteration over methodFinder.NumMethod() will still go over the other tests of the suite which are possibly not skipped and will run the SetupSuite. However, because you only specified MyTest, they won't run either. Now the SetupSuite is executed unnecessarily.

@dolmen dolmen added enhancement pkg-suite Change related to package testify/suite labels May 25, 2025
@dolmen
Copy link
Collaborator

dolmen commented May 25, 2025

I don't see how the two changes are related.

Please resubmit as 2 independent PRs.

@dolmen dolmen changed the title Add support for extra filtering and -testify.r suite: Add support for extra filtering and -testify.r May 25, 2025
@renzoarreaza
Copy link
Contributor Author

Fair enough. I've created #1749 and #1750 for the two changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement pkg-suite Change related to package testify/suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants