When running unit tests you may need to do some preparatory and/or cleanup work.
When running unit tests you may need to do some preparatory and/or cleanup work.
Ideally this should be in the setupAll and tearDownAll methods in your unit tests.
If that isn't possible, then Critical Test allows you to specify hooks that are run before and after the unit tests are run.
The Critical Test hooks are particularly useful for starting/stopping services (a database, docker container etc) before/after you run your unit tests.
A hook can be any executable such as a DCli (Dart), Bash script, CMD ....
To create a hook, create a critical_test directory under your project's 'tool' directory
tool\critical_test
pre_hooks are run before the unit tests start. post_hooks are run after all unit tests have been completed.
Pre/Post hooks will also run when you use the --single switch.
You can suppress hooks by passing in the --no-hooks flag.