If you use runSandwichWithCommandLineArgs, then you can control your tests with command line arguments. This section contains a quick overview of the available arguments, and explains how you can add your own custom ones.
- Choose a formatter:
- Choose a default log level:
- Repeat the test suite N times:
--repeat n(useful to exercise flaky tests)
- Filter the test tree to a string:
- Learn about extra flags controlling extensions:
- List test modules and flags to run them individually:
--list-tests. (Requires the use of test discovery.)
This list isn't exhaustive; to learn more about shorthands and other options pass
For more complex tests, you may want to be able to control them with custom command line arguments. To do this, you can write your own set of options with optparse-applicative and run your tests with runSandwichWithCommandLineArgs'. The primed version accepts your custom options parser.
This will cause your options to be parsed along with the default ones. To obtain the full command line options inside a test, call getCommandLineOptions. This will return a CommandLineOptions a, where
a is your custom options type. A convenient helper is getUserCommandLineOptions, which returns only the
a without the built-in stuff.
Now we can run this with
and the tests will use our custom values.