urchin/readme.md

59 lines
1.9 KiB
Markdown
Raw Normal View History

2012-10-08 10:01:29 -04:00
, , ,_ _, , , ___, , ,
| | |_) / |_|, ' | |\ |
'\__| '| \ '\_ '| | _|_, |'\|
` ' ` ` ' ` ' ' `
2012-10-10 12:53:03 -04:00
Urchin is a test framework for shell.
2012-10-08 10:01:29 -04:00
## Install
2012-10-08 10:35:58 -04:00
Download Urchin like so (as root)
2012-10-08 10:01:29 -04:00
2012-10-08 10:03:50 -04:00
wget -O /usr/local/bin https://raw.github.com/scraperwiki/urchin/master/urchin
chmod +x /usr/local/bin/urchin
2012-10-08 10:01:29 -04:00
Now you can run it.
2012-10-10 15:51:06 -04:00
urchin <test directory>
2012-10-08 10:01:29 -04:00
## Writing tests
2012-10-08 10:13:43 -04:00
Make a root directory for your tests. Inside it, put executable files that
2012-10-08 10:16:49 -04:00
exit `0` on success and something else on fail. Non-executable files and hidden
files (dotfiles) are ignored, so you can store fixtures right next to your
tests. Run urchin from inside the tests directory.
2012-10-08 10:01:29 -04:00
2012-10-10 12:53:03 -04:00
Urchin only cares about the exit code, so you can actually write your tests
in any language, not just shell.
2012-10-08 10:01:29 -04:00
## More about writing tests
2012-10-04 07:22:44 -04:00
Tests are organized recursively in directories, where the names of the files
and directories have special meanings.
tests/
setup
2012-10-10 15:47:21 -04:00
setup_dir
2012-10-04 07:22:44 -04:00
bar/
setup
test_that_something_works
2012-10-08 09:54:59 -04:00
teardown
2012-10-04 07:22:44 -04:00
baz/
jack-in-the-box/
setup
test_that_something_works
teardown
cat-in-the-box/
2012-10-08 09:54:59 -04:00
fixtures/
thingy.pdf
test_thingy
teardown
2012-10-04 07:22:44 -04:00
Directories are processed in a depth-first order. When a particular directory
2012-10-10 15:47:21 -04:00
is processed, `setup_dir` is run before everything else in the directory, including
subdirectories. `teardown_dir` is run after everything else in the directory.
2012-10-04 07:22:44 -04:00
2012-10-10 15:47:21 -04:00
A directory's `setup` file, if it exists, is run right before each test file
within the particular directory, and the `teardown` file is run right after.
2012-10-04 07:22:44 -04:00
2012-10-08 10:16:49 -04:00
Files are only run if they are executable, and files beginning with `.` are
2012-10-08 10:24:32 -04:00
ignored. Thus, fixtures and libraries can be included sloppily within the test
directory tree. The test passes if the file exits 0; otherwise, it fails.