Reputation: 1598
I have been working on debugging my app for a few hours now. I type rake test
to get a report on my errors. For no reason apparent to me, all of a sudden the output of rake test
is
Run options: --seed 33507
# Running:
........................EEEEEEE...........................E...........E.E.EF..EE...............................F.......F..EE....................FEEE..............................................
Only minutes earlier this command showed me the result of each test. What am I doing wrong?
Upvotes: 0
Views: 473
Reputation: 27875
The problem is a exit
in the code.
The exit
stops the execution before the test results are written.
A minimal example to repeat the problem:
class MyTest < MiniTest::Test
@@x = 0
def test_true
@@x += 1
assert true
end
def test_exit
exit 0 if @@x > 0
end
def test_false
assert false
end
end
Depending on the sequence order you get different results:
Run options: --seed 21072
# Running:
F..
Finished in 0.001011s, 2967.6086 runs/s, 1978.4057 assertions/s.
1) Failure:
MyTest#test_false [test.rb:13]:
Failed assertion, no message given.
3 runs, 2 assertions, 1 failures, 0 errors, 0 skips
Or another result:
Run options: --seed 10907
# Running:
F.
Background: Minitest executes the tests in random order. With the seed you can repeat your test in the same sequence.
In my example --seed 10907
executes first test_true
, then test_exit
with the executed exit
-statement - and the output is lost.
With --seed 21072
the test_exit
is executed before test_true
and the exit
is not executed. You get the result.
Upvotes: 2