I was surprised when I searched in Google for ways of running a custom TestRunner in a Rake::TestTask and I couldn’t find anything directly.
So after figuring out myself how it’s done I decided to share it here:
Let’s say that you have the following TestRunner (learn how to write your custom TestRunner)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
This new StatRunner is very simple and the only customization is that it prints the result line wrapped in a box.
Now imagine that this StatRunner is defined in the test/stat_runner.rb file. The rake task in the rakefile would look like:
1 2 3 4 5 6 7 8 9 | |
That’s it. Now if you run your rakefile you’ll get
Started ======================================================================== | Finished in 0.000103 seconds. | ======================================================================== 1 tests, 1 assertions, 0 failures, 0 errors