Skip to content

Commit 0b427af

Browse files
committed
Add tests styleguide
1 parent 5605aab commit 0b427af

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--
2+
### Writing tests
3+
4+
See also the [Bash style guide](../README.md)
5+
6+
--
7+
##### all tests should use `set -e` and call `setup` before making any assertions
8+
9+
Like this:
10+
11+
```bash
12+
begin_test "echo works"
13+
(
14+
set -e
15+
setup
16+
17+
echo passing | grep passing
18+
)
19+
end_test
20+
```
21+
22+
--
23+
##### Resist the urge to disable `set -e`
24+
25+
If you want to assert failure, please resist the urge to disable `set -e` and
26+
instead use negation with `!`:
27+
28+
```bash
29+
begin_test "netcat is not from bsd"
30+
(
31+
set -e
32+
setup
33+
34+
! nc -h 2>&1 | grep bsd
35+
)
36+
end_test
37+
```

0 commit comments

Comments
 (0)