2019-03-04 23:52:53 +00:00
# Bats-core: Bash Automated Testing System (2018)
[![Latest release ](https://img.shields.io/github/release/bats-core/bats-core.svg )](https://github.com/bats-core/bats-core/releases/latest)
[![npm package ](https://img.shields.io/npm/v/bats.svg )](https://www.npmjs.com/package/bats)
2022-01-17 13:58:05 +00:00
[![License: MIT ](https://img.shields.io/badge/License-MIT-yellow.svg )](https://github.com/bats-core/bats-core/blob/master/LICENSE.md)
[![Continuous integration status ](https://github.com/bats-core/bats-core/workflows/Tests/badge.svg )](https://github.com/bats-core/bats-core/actions?query=workflow%3ATests)
[![Read the docs status ](https://readthedocs.org/projects/bats-core/badge/ )](https://bats-core.readthedocs.io)
2019-03-04 23:52:53 +00:00
[![Join the chat in bats-core/bats-core on gitter ](https://badges.gitter.im/bats-core/bats-core.svg )][gitter]
2021-05-03 12:43:04 +00:00
Bats is a [TAP ](https://testanything.org/ )-compliant testing framework for Bash. It provides a simple
2019-03-04 23:52:53 +00:00
way to verify that the UNIX programs you write behave as expected.
[TAP]: https://testanything.org
A Bats test file is a Bash script with special syntax for defining test cases.
Under the hood, each test case is just a function with a description.
```bash
#!/usr/bin/env bats
@test "addition using bc" {
result="$(echo 2+2 | bc)"
[ "$result" -eq 4 ]
}
@test "addition using dc" {
result="$(echo 2 2+p | dc)"
[ "$result" -eq 4 ]
}
```
Bats is most useful when testing software written in Bash, but you can use it to
test any UNIX program.
Test cases consist of standard shell commands. Bats makes use of Bash's
`errexit` (`set -e`) option when running test cases. If every command in the
test case exits with a `0` status code (success), the test passes. In this way,
each line is an assertion of truth.
2021-05-03 12:43:04 +00:00
## Table of contents
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
**NOTE** The documentation has moved to < https: / / bats-core . readthedocs . io >
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
<!-- toc -->
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
- [Testing ](#testing )
2019-03-04 23:52:53 +00:00
- [Support ](#support )
2021-05-03 12:43:04 +00:00
- [Contributing ](#contributing )
- [Contact ](#contact )
2019-03-04 23:52:53 +00:00
- [Version history ](#version-history )
- [Background ](#background )
2022-01-17 13:58:05 +00:00
* [What's the plan and why? ](#whats-the-plan-and-why )
* [Why was this fork created? ](#why-was-this-fork-created )
2019-03-04 23:52:53 +00:00
- [Copyright ](#copyright )
2021-05-03 12:43:04 +00:00
<!-- tocstop -->
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
## Testing
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
```sh
bin/bats --tap test
2019-03-04 23:52:53 +00:00
```
2021-05-03 12:43:04 +00:00
See also the [CI ](./.github/workflows/tests.yml ) settings for the current test environment and
scripts.
2019-03-04 23:52:53 +00:00
## Support
The Bats source code repository is [hosted on
GitHub](https://github.com/bats-core/bats-core). There you can file bugs on the
issue tracker or submit tested pull requests for review.
For real-world examples from open-source projects using Bats, see [Projects
Using Bats](https://github.com/bats-core/bats-core/wiki/Projects-Using-Bats) on
the wiki.
To learn how to set up your editor for Bats syntax highlighting, see [Syntax
Highlighting](https://github.com/bats-core/bats-core/wiki/Syntax-Highlighting)
on the wiki.
2021-05-03 12:43:04 +00:00
## Contributing
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
For now see the [`docs` ](docs ) folder for project guides, work with us on the wiki
or look at the other communication channels.
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
## Contact
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
- We are `#bats` on freenode;
- Or leave a message on [gitter].
## Version history
See `docs/CHANGELOG.md` .
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
## Background
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
<!-- markdownlint - disable MD026 -->
2019-03-04 23:52:53 +00:00
### What's the plan and why?
2021-05-03 12:43:04 +00:00
<!-- markdownlint - enable MD026 -->
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
**Tuesday, September 19, 2017:** This was forked from [Bats][bats-orig] at
commit [0360811][]. It was created via `git clone --bare` and `git push
--mirror`.
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
[bats-orig]: https://github.com/sstephenson/bats
[0360811]: https://github.com/sstephenson/bats/commit/03608115df2071fff4eaaff1605768c275e5f81f
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
This [bats-core repo ](https://github.com/bats-core/bats-core ) is the community-maintained Bats project.
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
<!-- markdownlint - disable MD026 -->
### Why was this fork created?
<!-- markdownlint - enable MD026 -->
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
There was an initial [call for maintainers][call-maintain] for the original Bats repository, but write access to it could not be obtained. With development activity stalled, this fork allowed ongoing maintenance and forward progress for Bats.
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
[call-maintain]: https://github.com/sstephenson/bats/issues/150
2019-03-04 23:52:53 +00:00
## Copyright
2022-01-17 13:58:05 +00:00
© 2017-2021 bats-core organization
2019-03-04 23:52:53 +00:00
2021-05-03 12:43:04 +00:00
© 2011-2016 Sam Stephenson
2019-03-04 23:52:53 +00:00
Bats is released under an MIT-style license; see `LICENSE.md` for details.
2021-05-03 12:43:04 +00:00
See the [parent project ](https://github.com/bats-core ) at GitHub or the
[AUTHORS ](AUTHORS ) file for the current project maintainer team.
2019-03-04 23:52:53 +00:00
[gitter]: https://gitter.im/bats-core/bats-core?utm_source=badge& utm_medium=badge& utm_campaign=pr-badge& utm_content=badge