urchin/readme.md

61 lines
2.0 KiB
Markdown
Raw Normal View History

2012-10-04 11:22:44 +00:00
2012-10-08 14:01:29 +00:00
, , ,_ _, , , ___, , ,
| | |_) / |_|, ' | |\ |
'\__| '| \ '\_ '| | _|_, |'\|
` ' ` ` ' ` ' ' `
Urchin is an experimental language-agnostic lightweight cross-platform test skeleton
written in POSIX-compliant shell, originally designed for test-driven server deployment
at <a href="https://scraperwiki.com">ScraperWiki</a>.
## Install
2012-10-08 14:03:50 +00:00
Downlolad Urchin like so (as root)
2012-10-08 14:01:29 +00:00
2012-10-08 14:03:50 +00:00
wget -O /usr/local/bin https://raw.github.com/scraperwiki/urchin/master/urchin
chmod +x /usr/local/bin/urchin
2012-10-08 14:01:29 +00:00
Now you can run it.
2012-10-08 14:04:23 +00:00
urchin
2012-10-08 14:01:29 +00:00
## Writing tests
2012-10-08 14:13:43 +00:00
Make a root directory for your tests. Inside it, put executable files that
2012-10-08 14:16:49 +00: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 14:01:29 +00:00
## More about writing tests
2012-10-04 11:22:44 +00:00
Tests are organized recursively in directories, where the names of the files
and directories have special meanings.
tests/
setup
bar/
setup
test_that_something_works
2012-10-08 13:54:59 +00:00
teardown
2012-10-04 11:22:44 +00:00
baz/
jack-in-the-box/
setup
test_that_something_works
teardown
cat-in-the-box/
2012-10-08 13:54:59 +00:00
fixtures/
thingy.pdf
test_thingy
teardown
2012-10-04 11:22:44 +00:00
Directories are processed in a depth-first order. When a particular directory
is processed, `setup` is run before everything else in the directory, including
subdirectories. Use `urchin_export`, which works like `export`, to set variables
in the setup function and make them available to other files in the same
directory.
`teardown` is run after everything else in the directory. The "everything else"
actually only includes files whose names contain "test". The test passes if the
file exits 0; otherwise, it fails.
2012-10-08 14:16:49 +00:00
Files are only run if they are executable, and files beginning with `.` are
ignored. Thus, fixtures and libraries can be included
2012-10-04 11:22:44 +00:00
sloppily within the test directory tree.