I’m pleased to announce BareTest 0.2.
BareTest is a new test framework. I started writing it for mainly 2
reasons:
- I disliked the undescriptive way you have specify tests in vanilla
Test::Unit
(def test_bla), compared to the much more descriptive way you do it in
e.g.
rspec (it “should have a very nice description”) - I was pretty sure a decent test framework could be written in under
100 lines
of code (and the first version of baretest, written on the flight home
from
railsconf09 in vegas, was indeed a whopping 37 lines of code)
By this version, baretest has gotten some - to my knowledge - unique or
at least
rare features. Those include:
- Very straightforward and terse assertions (just a block whose return
value
defines success/failure). - Various helpers to write assertions with better diagnostic messages
and
more complex tasks like raising, throwing, float imprecision,
unordered
collections etc. - Easy grouping of assertions into suites.
- BDD style specifications/test descriptions (NOT code) that can be
extracted
without running the testcode. - An interactive mode, letting you examine what went wrong in a
failing/erroring
test within an irb session, bound to the context of the assertion that
failed,
showing you the full code of the assertion, even including it in the
readline-
history of that irb session. - An uncomplicated way to write pending assertions, have dependency
testing and
skip certain suites/assertions. - A colored shell formatter, diagnostic-, XML- and TAP formatter.
- Adding your own formatters is trivial - a module with 4 methods to
wrap. The
average formatter shipped with baretest is between 20 and 50 lines. - An API to use it from code, such as rake tasks (includes an example
rake-task) - A ‘baretest’ executable to run tests on multiple files at once, using
a test-
layout convention to reduce require- and
setup-path-manipulation-orgies
The Links:
Home: http://projects.sr.brightlight.ch/projects/show/baretest
Github: GitHub - apeiros/baretest: A testframework that doesn't stand in your way or forces you to learn a new language. Two methods is all that is required to know. If you need it, it provides you with all kinds of features to support you writing your tests.
Rubyforge: http://baretest.rubyforge.org
API: http://baretest.rubyforge.org/docs-0.2.0/
How to quickly try baretest without installing it:
- Download from github and unpack (or clone) - download link:
http://github.com/apeiros/baretest/tarball/8954b17def1899a10b0e6fff39ced07f6eb722ef - Change into the baretest directory:
cd the/baretest/directory
- Run the examples:
./bin/baretest examples/test.rb
That’s it. Alternatively you can run baretest’s own tests, and/or play
with
formatters: ./bin/baretest -f tap
Installing baretest
- run
gem install baretest
(you may have to runsudo gem install baretest
) - There is no 2.
Installing baretest edge
- Download from github (or clone)
- Run
rake gem:install
(you may have to runsudo rake gem:install
)
Note for users with multiple ruby installations: the rake task will try
to use
the right gem executable. You can force it to use a specific one by
setting
the GEM env variable, e.g.: rake gem:install GEM='gem1.9'
Using baretest
- In your project directory, run
baretest --init
, which will create a
‘tests’
directory with all the basic stuff already in it. - Write your tests
- Run them using
baretest
in the toplevel directory of your project.
That’s all folks.
Looking forward to your feedback and hope you enjoy baretest
Regards
Stefan R., aka apeiros