Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spencertipping/lazytest
Tests for lazy developers (not that I know of any)
https://github.com/spencertipping/lazytest
Last synced: 7 days ago
JSON representation
Tests for lazy developers (not that I know of any)
- Host: GitHub
- URL: https://github.com/spencertipping/lazytest
- Owner: spencertipping
- License: mit
- Created: 2016-08-28T22:06:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-10-30T19:04:01.000Z (about 3 years ago)
- Last Synced: 2024-08-01T13:36:54.459Z (3 months ago)
- Language: Perl
- Size: 8.79 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LazyTest: tests for developers too lazy to write them
[MIT license as usual](LICENSE)I don't mind writing documentation that includes examples, but I don't really
like to write tests. LazyTest finds `bash` fenced code regions in Markdown
files and interprets them as examples that should produce the demonstrated
output. For example:```bash
$ seq 4 # command with output below
1
2
3
4
```This works by compiling Markdown files into bash scripts that contain the
assertions.## Using LazyTest
```sh
$ ./lazytest *.md > tests.sh
$ bash tests.sh && echo 'woohoo, everything works'
```You can write shell script snippets that aren't tests by using `sh` instead of
`bash`; for example:```sh
# this code region won't turn into a test
$ false
woohoo, you ran /bin/false!
```## How to write examples
LazyTest is pretty good at figuring out what's a command and what's
expected-output, but there are a few things that can throw it off. First,
things that work:### Multiline strings
These work most of the time because lazytest reads until it has an even number
of them.```bash
$ echo 'multiline single-
quoted strings' | perl -lne 'print "$_ FTW"'
multiline single- FTW
quoted strings FTW
``````bash
$ echo "that's confusing"
that's confusing
``````bash
$ echo "it's also possible
to have multiline double quoted strings"
it's also possible
to have multiline double quoted strings
```### Line continuations
```bash
$ seq 1 \
5
1
2
3
4
5
```### Heredocs
You can have a heredoc and lazytest will figure out where it ends:```bash
$ cat <