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

Add global setup/teardown hooks for test suites #251

Open
kikijiki opened this issue Dec 28, 2024 · 2 comments · May be fixed by #256
Open

Add global setup/teardown hooks for test suites #251

kikijiki opened this issue Dec 28, 2024 · 2 comments · May be fixed by #256

Comments

@kikijiki
Copy link

It would be helpful to have support for global setup and teardown functions that run once before all tests begin and after all tests complete, respectively. This pattern is common in testing frameworks.

@sunshowers
Copy link
Member

Sure, seems reasonable. I don't plan to work on this myself unless my employer or I need it, but if you'd like to contribute this feature I'd be happy to review it.

In #254 I converted the macro to use a tt-muncher, which should make this easier. I'd write this as optional setup and teardown arguments. Things to consider include:

  • Should the list of tests/files to execute be provided to the setup function? If so, how, in a
    way that ensures forward compatibility?
  • If there are multiple setup and teardown arguments, how should they be ordered?
  • Should the functions be called if there are no tests? (I'd lean towards no, due to nextest compatibility -- setup and teardown will effectively be called once per test with nextest).
  • For the teardown function, how should the statuses be provided?

If you can write up a design proposal, we can go over that before you get to implementing it.

kikijiki added a commit to kikijiki/datatest-stable that referenced this issue Dec 29, 2024
kikijiki added a commit to kikijiki/datatest-stable that referenced this issue Dec 29, 2024
@kikijiki kikijiki linked a pull request Dec 29, 2024 that will close this issue
@kikijiki
Copy link
Author

I made a quick PR to illustrate what I had in mind.

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

Successfully merging a pull request may close this issue.

2 participants