2024-02-25 02:33:51 +11:00
|
|
|
# bats
|
|
|
|
|
|
|
|
> Bash Automated Testing System: a TAP (<https://testanything.org/>) compliant testing framework for Bash.
|
|
|
|
> More information: <https://bats-core.readthedocs.io/en/stable/usage.html>.
|
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Run a BATS test script and output results in the TAP (Test Anything Protocol) format:
|
2024-02-25 02:33:51 +11:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`bats {{[-t|--tap]}} {{path/to/test.bats}}`
|
2024-02-25 02:33:51 +11:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Count test cases of a test script without running any tests:
|
2024-02-25 02:33:51 +11:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`bats {{[-c|--count]}} {{path/to/test.bats}}`
|
2024-02-25 02:33:51 +11:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Run BATS test cases recursively (files with a `.bats` extension):
|
2024-02-25 02:33:51 +11:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`bats {{[-r|--recursive]}} {{path/to/directory}}`
|
2024-02-25 02:33:51 +11:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Output results in a specific format:
|
2024-02-25 02:33:51 +11:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`bats {{[-F|--formatter]}} {{pretty|tap|tap13|junit}} {{path/to/test.bats}}`
|
2024-07-11 07:42:29 +10:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Add timing information to tests:
|
2024-07-11 07:42:29 +10:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`bats {{[-T|--timing]}} {{path/to/test.bats}}`
|
2024-07-11 07:42:29 +10:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Run specific number of jobs in parallel (requires GNU `parallel` to be installed):
|
2024-07-11 07:42:29 +10:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`bats {{[-j|--jobs]}} {{number}} {{path/to/test.bats}}`
|