I'm working on something new: a logger that complements Ruby gem minitest
.
One of its features is analysis of certain failed verdicts, namely those involving collections.
Here's a small test that compares two hashes:
require 'minitest_log'
class Example < Minitest::Test
def test_example
MinitestLog.open do |log|
expected = {:a => 0, :b => 1, :c => 2, :d => 3, :e => 4, :f => 5}
actual = {:h => 5, :g => 4, :d => 1, :c => 0, :b => 1, :a => 0}
log.verdict_assert_equal?(:analyzed, expected, actual)
end
end
end
The log of course shows the failed verdict, along with the expected and actual values.
It also contains this:
<analysis>
<missing e='4' f='5'/>
<unexpected h='5' g='4'/>
<changed c='{:expected=>2, :actual=>0}' d='{:expected=>3, :actual=>1}'/>
<ok a='0' b='1'/>
</analysis>
Here's the log:
<log>
<summary verdicts='1' failures='1' errors='0'/>
<verdict method='verdict_assert_equal?' outcome='failed' id='analyzed'>
<exp_value a='0' b='1' c='2' d='3' e='4' f='5'/>
<act_value h='5' g='4' d='1' c='0' b='1' a='0'/>
<analysis>
<missing e='4' f='5'/>
<unexpected h='5' g='4'/>
<changed c='{:expected=>2, :actual=>0}' d='{:expected=>3, :actual=>1}'/>
<ok a='0' b='1'/>
</analysis>
<exception class='Minitest::Assertion'>
<message>
--- expected +++ actual @@ -1 +1 @@ -{:a=>0, :b=>1, :c=>2,
:d=>3, :e=>4, :f=>5} +{:h=>5, :g=>4, :d=>1, :c=>0,
:b=>1, :a=>0}
</message>
<backtrace>
<![CDATA[
example.rb:23:in `block in test_example'
example.rb:6:in `test_example']]>
</backtrace>
</exception>
</verdict>
</log>
Top comments (0)