Movatterモバイル変換


[0]ホーム

URL:


Test Anything Protocol


Testing with Ruby

Testing with Ruby is pretty easy, however, there is a lesser known Ruby program, that produces TAP output (on demand). This handy program isbacon. You can install it using the RubyGems Ruby package management system. Just do (possibly as a privileged user):

$geminstallbacon

Now you can create tests. Create a Ruby file test.rb (or something like that):

describe"a example test suite"doit"should consider true as the truth"dotrue.should.be.trueendit"should consider false as the truth, too"dofalse.should.be.trueendend

Once you created your this file, you can issue the command

$bacon test.rb--tap

which, in turn, produces the following TAP output (Version 12)

ok 1   - should consider true as the truthnot ok 2 - should consider false as the truth, too: FAILED# Bacon::Error: false.true?() failed# ./test.rb:7: a example test suite - should consider false as the truth, too# ./test.rb:6# ./test.rb:11..2# 2 tests, 2 assertions, 1 failures, 0 errors

github.com/testanything


[8]ページ先頭

©2009-2025 Movatter.jp