1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-11-17 11:42:33 +01:00

Document test suites

This commit is contained in:
Sam Stephenson 2012-11-16 15:32:30 -06:00
parent 04be7dc717
commit 392d2fa6a0

View File

@ -22,11 +22,16 @@ description.
} }
``` ```
Bats is most useful when testing software written in Bash, but you can
use it to test any UNIX program.
Test cases consist of standard shell commands. Bats makes use of Test cases consist of standard shell commands. Bats makes use of
Bash's `errexit` (`set -e`) option when running test cases. If every Bash's `errexit` (`set -e`) option when running test cases. If every
command in the test case exits with a `0` status code (success), the command in the test case exits with a `0` status code (success), the
test passes. In this way, each line is an assertion of truth. test passes. In this way, each line is an assertion of truth.
## Running tests
To run your tests, invoke the `bats` interpreter with a path to a test To run your tests, invoke the `bats` interpreter with a path to a test
file. The file's test cases are run sequentially and in isolation, and file. The file's test cases are run sequentially and in isolation, and
the results are written to standard output in human-readable [TAP the results are written to standard output in human-readable [TAP
@ -45,8 +50,12 @@ You can also define special `setup` and `teardown` functions which run
before and after each test case, respectively. Use these to load before and after each test case, respectively. Use these to load
fixtures, set up your environment, and clean up when you're done. fixtures, set up your environment, and clean up when you're done.
Bats is most useful when testing software written in Bash, but you can ### Test suites
use it to test any UNIX program.
You can also invoke the `bats` interpreter with a path to a directory
containing multiple `.bats` files. Bats will run each test file
individually and aggregate the results. If any test case fails, `bats`
exits with a `1` status code.
## Writing Bats tests ## Writing Bats tests