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

Wordsmithing

This commit is contained in:
Sam Stephenson 2011-12-30 14:04:14 -06:00
parent 1387d18328
commit 841d417b11

View File

@ -48,13 +48,15 @@ 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 Bats is most useful when testing software written in Bash, but you can
use it to test any UNIX program. use it to test any UNIX program.
## Writing Bats tests
### The _run_ helper ### The _run_ helper
You're probably most interested in testing a command's exit status and If you're using Bats, you're probably most interested in testing a
output. Bats includes a `run` helper that invokes its arguments as a command's exit status and output. Bats includes a `run` helper that
command, saves the exit status and output into special global invokes its arguments as a command, saves the exit status and output
variables, and then returns with a `0` status code so you can continue into special global variables, and then returns with a `0` status code
to make assertions in your test case. so you can continue to make assertions in your test case.
For example, let's say you're testing that the `foo` command, when For example, let's say you're testing that the `foo` command, when
passed a nonexistent filename, exits with a `1` status code and prints passed a nonexistent filename, exits with a `1` status code and prints
@ -119,7 +121,7 @@ in the test file.
* `$BATS_TMPDIR` is the location to a directory that may be used to * `$BATS_TMPDIR` is the location to a directory that may be used to
store temporary files. store temporary files.
### Installing Bats ## Installing Bats
Check out a copy of the Bats repository. Then, either add the Bats Check out a copy of the Bats repository. Then, either add the Bats
`bin` directory to your `$PATH`, or run the provided `install.sh` `bin` directory to your `$PATH`, or run the provided `install.sh`
@ -133,7 +135,7 @@ Bats. For example, to install Bats into `/usr/local`,
Note that you may need to run `install.sh` with `sudo` if you do not Note that you may need to run `install.sh` with `sudo` if you do not
have permission to write to the installation prefix. have permission to write to the installation prefix.
### Contributing ## Contributing
The Bats source code repository is [hosted on The Bats source code repository is [hosted on
GitHub](https://github.com/sstephenson/bats). There you can file bugs GitHub](https://github.com/sstephenson/bats). There you can file bugs