Skip to content

Commit

Permalink
Merge pull request #431 from rico-chet/patch-1
Browse files Browse the repository at this point in the history
docs/writing-tests: Fix heading levels
  • Loading branch information
martin-schulze-vireso committed Apr 23, 2021
2 parents b81de28 + 3d42bc1 commit 04f6323
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions docs/source/writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ is equivalent to
var=$(command args ...)
```

#### Comment syntax
## Comment syntax

External tools (like `shellcheck`, `shfmt`, and various IDE's) may not support
the standard `.bats` syntax. Because of this, we provide a valid `bash`
Expand All @@ -120,7 +120,7 @@ function invoking_foo_without_arguments_prints_usage { #@test
When using this syntax, the function name will be the title in the result output
and the value checked when using `--filter`.

### `load`: Share common code
## `load`: Share common code

You may want to share common code across multiple test files. Bats includes a
convenient `load` command for sourcing a Bash source file relative to the
Expand All @@ -146,7 +146,7 @@ will _not_ be made available to callers of `load`.
> it looks for `test_helper`). This behaviour is deprecated and subject to
> change, please use exact filenames instead.
### `skip`: Easily skip tests
## `skip`: Easily skip tests

Tests can be skipped by using the `skip` command at the point in a test you wish
to skip.
Expand Down Expand Up @@ -184,7 +184,7 @@ Or you can skip conditionally:

__Note:__ `setup` and `teardown` hooks still run for skipped tests.

### `setup` and `teardown`: Pre- and post-test hooks
## `setup` and `teardown`: Pre- and post-test hooks

You can define special `setup` and `teardown` functions, which run before and
after each test case, respectively. Use these to load fixtures, set up your
Expand Down Expand Up @@ -216,7 +216,7 @@ teardown_file # from file 2, on leaving file 2
</details>
<!-- markdownlint-enable MD033 -->

### Code outside of test cases
## Code outside of test cases

You can include code in your test file outside of `@test` functions. For
example, this may be useful if you want to check for dependencies and fail
Expand All @@ -225,7 +225,7 @@ outside of `@test`, `setup` or `teardown` functions must be redirected to
`stderr` (`>&2`). Otherwise, the output may cause Bats to fail by polluting the
TAP stream on `stdout`.

### File descriptor 3 (read this if Bats hangs)
## File descriptor 3 (read this if Bats hangs)

Bats makes a separation between output from the code under test and output that
forms the TAP stream (which is produced by Bats internals). This is done in
Expand All @@ -246,7 +246,7 @@ amount of time.
**To prevent this from happening, close FD 3 explicitly when running any command
that may launch long-running child processes**, e.g. `command_name 3>&-` .

### Printing to the terminal
## Printing to the terminal

Bats produces output compliant with [version 12 of the TAP protocol][TAP]. The
produced TAP stream is by default piped to a pretty formatter for human
Expand Down Expand Up @@ -290,7 +290,7 @@ your custom text. Here are some detailed guidelines to refer to:

[tap-plan]: https://testanything.org/tap-specification.html#the-plan

### Special variables
## Special variables

There are several global variables you can use to introspect on Bats tests:

Expand All @@ -309,7 +309,7 @@ There are several global variables you can use to introspect on Bats tests:
(default: `$BATS_TMPDIR/bats-run-$BATS_ROOT_PID-XXXXXX`)
- `$BATS_FILE_EXTENSION` (default: `bats`) specifies the extension of test files that should be found when running a suite (via `bats [-r] suite_folder/`)

### Libraries and Add-ons
## Libraries and Add-ons

Bats supports loading external assertion libraries and helpers. Those under `bats-core` are officially supported libraries (integration tests welcome!):

Expand Down

0 comments on commit 04f6323

Please sign in to comment.