Skip to content
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

Provide ability to run a setup/teardown method once per execution of the test runner #2224

Closed
TheFriendlyCoder opened this issue May 11, 2024 · 1 comment

Comments

@TheFriendlyCoder
Copy link

Right now the test runner supports setUpAll / tearDownAll methods for test suites. The documentation for these implies that these methods are run ONCE for all tests that are executed, which isn't entirely correct. When you split your test suite up into separate test modules / files, each one has its own independent setUpAll / tearDownAll methods. This makes it impossible to run bootstrapping code once, and only once, for all tests that are executed by the test suite regardless of where they are defined. This would be a helpful feature to have.

Example use cases:

  • Suppose you have an entire suite of tests for a project, spread across multiple files / modules and they all make use of a Dockerized test environment. It stands to reason that you'd want to launch the Docker environment once at the start of the test suite, then run all tests against it, and then shut down the container once after all tests have been completed
  • Suppose you have a project which needs to interact with a remote API. It stands to reason that one might want to create a single HTTP session (ie: authenticated) to that service and then share the session across all tests in the suite. It would be helpful to construct and initialize this session once before any test in the suite begins, regardless of which file/module it is defined in, and then have that session shared across all tests, and then have the session closed once all tests are completed.
@jakemac53
Copy link
Contributor

See #1759, this isn't really feasible with the current design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants