= MiniTap

Given a MiniTest testcase:

class ExampleTestCase < MiniTest::Unit::TestCase def test_error raise end

def test_failing
  assert_equal('1', '2')
end

def test_passing
  sleep 1
  assert_equal('1', '1')
end

end

Running it with the TAP-Y format should work without error.

The resulting document stream should exhibit the following characteristics.

There should be six sections.

@stream.size #=> 6

The first should be a suite with a count of 3.

@stream.first #=> ‘suite’ @stream.first #=> 3

The second should be case entry.

@stream[‘type’] #=> ‘case’ @stream[‘label’] #=> ‘ExampleTestCase’ @stream[‘level’] #=> 0

The next three documents are the unit tests, which can occur in any order. There one that shoud have a status of pass, another of fail and the third of error.

passing_test = @stream.find{ |d| d == ‘test’ && d == ‘pass’ } failing_test = @stream.find{ |d| d == ‘test’ && d == ‘fail’ } erring_test = @stream.find{ |d| d == ‘test’ && d == ‘error’ }

The passing test should have the following charactersitics.

passing_test #=> ‘test_passing’

The failing test should

failing_test #=> “test_failing” failing_test[‘class’] #=> “MiniTest::Assertion” failing_test[‘file’] #=> “test.rb” failing_test[‘line’] #=> 13 failing_test[‘source’] #=> “assert_equal(‘1’, ‘2’)”

The failing test should also not have any mention of minitap in the backtrace.

failing_test[‘backtrace’].each do |e| /minitap/.refute.match(e) end

The erring test should

erring_test #=> ‘test_error’ erring_test[‘class’] #=> ‘RuntimeError’ erring_test[‘file’] #=> ‘test.rb’ erring_test[‘line’] #=> 9 erring_test[‘source’] #=> ‘raise’

The erring test should also not have any mention of minitap in the backtrace.

erring_test[‘backtrace’].each do |e| /minitap/.refute.match(e) end

The last should a final document.

@stream.last #=> ‘final’

And it should have the following counts.

@stream.last[‘total’] #=> 3 @stream.last[‘error’] #=> 1 @stream.last[‘fail’] #=> 1 @stream.last[‘pass’] #=> 1 @stream.last[‘omit’] #=> 0 @stream.last[‘todo’] #=> 0