1BATS(1)                                                                BATS(1)
2
3
4

NAME

6       bats - Bash Automated Testing System
7

SYNOPSIS

9       bats [-c] [-p | -t] test [test ...]
10
11       test  is  the path to a Bats test file, or the path to a directory con‐
12       taining Bats test files.
13

DESCRIPTION

15       Bats is a TAP-compliant testing framework for Bash. It provides a  sim‐
16       ple way to verify that the UNIX programs you write behave as expected.
17
18       A Bats test file is a Bash script with special syntax for defining test
19       cases. Under the hood, each  test  case  is  just  a  function  with  a
20       description.
21
22       Test cases consist of standard shell commands. Bats makes use of Bash´s
23       errexit (set -e) option when running test cases. If  every  command  in
24       the test case exits with a 0 status code (success), the test passes. In
25       this way, each line is an assertion of truth.
26
27       See bats(7) for more information on writing Bats tests.
28

RUNNING TESTS

30       To run your tests, invoke the bats interpreter with a path  to  a  test
31       file.  The  file´s test cases are run sequentially and in isolation. If
32       all the test cases pass, bats exits with a 0 status code. If there  are
33       any failures, bats exits with a 1 status code.
34
35       You  can invoke the bats interpreter with multiple test file arguments,
36       or with a path to a directory containing  multiple  .bats  files.  Bats
37       will  run each test file individually and aggregate the results. If any
38       test case fails, bats exits with a 1 status code.
39

OPTIONS

41       -c, --count
42              Count the number of test cases without running any tests
43
44       -h, --help
45              Display help message
46
47       -p, --pretty
48              Show results in pretty format (default for terminals)
49
50       -t, --tap
51              Show results in TAP format
52
53       -v, --version
54              Display the version number
55

OUTPUT

57       When you run Bats from a terminal, you´ll see output as  each  test  is
58       performed, with a check-mark next to the test´s name if it passes or an
59       "X" if it fails.
60
61
62
63           $ bats addition.bats
64            ✓ addition using bc
65            ✓ addition using dc
66
67           2 tests, 0 failures
68
69
70
71       If Bats is not connected to a terminal--in other words, if you  run  it
72       from  a  continuous  integration  system  or  redirect  its output to a
73       file--the results are displayed in human-readable, machine-parsable TAP
74       format.  You can force TAP output from a terminal by invoking Bats with
75       the --tap option.
76
77
78
79           $ bats --tap addition.bats
80           1..2
81           ok 1 addition using bc
82           ok 2 addition using dc
83
84
85

EXIT STATUS

87       The bats interpreter exits with a value of 0 if all test cases pass, or
88       1 if one or more test cases fail.
89

SEE ALSO

91       Bats wiki: https://github.com/sstephenson/bats/wiki/
92
93       bash(1), bats(7)
94
96       (c) 2014 Sam Stephenson
97
98       Bats is released under the terms of an MIT-style license.
99
100
101
102                                  August 2014                          BATS(1)
Impressum