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       -r, --recursive
51              Include tests in subdirectories
52
53       -t, --tap
54              Show results in TAP format
55
56       -v, --version
57              Display the version number
58

OUTPUT

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

EXIT STATUS

90       The bats interpreter exits with a value of 0 if all test cases pass, or
91       1 if one or more test cases fail.
92

SEE ALSO

94       Bats wiki: https://github.com/bats-core/bats-core/wiki/
95
96       bash(1), bats(7)
97
99       (c) 2017 Bianca Tamayo (bats-core organization) (c) 2014 Sam Stephenson
100
101       Bats is released under the terms of an MIT-style license.
102
103
104
105                                  August 2014                          BATS(1)
Impressum