Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sebastiaan Verbeek
committed
Dec 16, 2020
1 parent
4683d58
commit a11cacf
Showing
4 changed files
with
58 additions
and
37 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# BATS testing framework | ||
|
||
This document is relevant starting from [v0.11.52](https://github.com/redkubes/otomi-core/releases/tag/v0.11.52). | ||
|
||
## Where can I find BATS? | ||
|
||
The otomi/tools:1.4.10 includes the [bats framework](https://github.com/bats-core/bats-core), including libraries [bats-assert](https://github.com/ztombol/bats-assert), [bats-file](https://github.com/ztombol/bats-support) and [bats-support](https://github.com/ztombol/bats-support). These links include relevant documentation, such as syntax, which won't be discussed on this page. | ||
|
||
Example of calling the binary: | ||
|
||
`docker run --rm otomi/tools:1.4.10 bats bin/tests` | ||
|
||
This example assumes tests exist in the container directory `otomi-core/bin/tests`. You can call bats with a directory as parameter and it will execute any `*.bats` file. | ||
|
||
## How should I add tests? | ||
|
||
Test files should have the .bats extension, otherwise they will not be executed. | ||
|
||
## How should I name the test files? | ||
|
||
Usually you will name the test file after the shell file holding the code you are testing, but with the `.bats` extension. | ||
|
||
Example with a bootstrap.sh file: | ||
|
||
`bootstrap.bats` | ||
|
||
## How do I use the BATS libraries? | ||
|
||
The tests will run in the otomi-core container, which has bats libs in `/usr/local/lib/bats-*`. The following snippet will include them in a test file: | ||
|
||
``` | ||
lib_dir="/usr/local/lib" | ||
load "$lib_dir/bats-support/load.bash" | ||
load "$lib_dir/bats-assert/load.bash" | ||
load "$lib_dir/bats-file/load.bash" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters