Last modified 4 years ago Last modified on 16.09.2013 01:32:25

Test::TAP::More for Ruby

Description

Test::TAP::More (or gem test-tap-more) is a simple test framework for Ruby. The framework is a TAP producer.

It is the only TAP producer for Ruby known to me that is sensibly published (with a license and being a gem), which was the main reason to create it.

Test::TAP::More mimics excellent Test::More module, because Test::More is easy to comprehend (and thus to learn) and it's simple to reimplement.

How to use

First, write some test cases:

#!/usr/bin/ruby
#
# t/00-load.trb: test loading "my/module"
#

require "test/tap/more"

plan :tests => 2

nothing_raised "loading my/module" do
  require "my/module"
end or BAIL_OUT "Can't load 'my/module'"

nothing_raised 'check version' do
  diag "Testing modmon/event #{My::Module::VERSION}, Ruby #{RUBY_VERSION}"
end

Remember to add #!/usr/bin/ruby line (or equivalent), as perl does some magic with it.

Now run this test:

$ perl -MTAP::Harness -e '
  $ENV{RUBYLIB} = "lib";
  $t = new TAP::Harness({ verbosity => $ENV{VERBOSE} });
  $t->runtests(@ARGV)
' t/*.trb

There is simpler way: use prove utility coming with Perl interpeter:

$ RUBYLIB=lib prove t/*.trb

Since Test::TAP::More produces TAP output, it can be used by any TAP consumer, including Smolder, test dashboard.

How to download

git clone http://dozzie.jarowit.net/code/ruby-test-tap-more.git

How to install

More or less standard Ruby procedure:

gem build *.gemspec
gem install *.gem

TODO

  • write documentation
  • add support for sub-tests
  • add support for skipping some tests
  • add support for TODO tests
  • add support for blocks in place of plain result
    • this could catch exceptions and checking value at the same test instead of two
  • publish the gem on RubyGems.org