MiniTest Testing Framework for SU
-
For those interested, heres what you need to be able to use Ruby 1.9 new unit testing framework in SU.
-
Download and unpack into su plugin folder
-
require "minitest/autorun" at the beginning of the script you want to be testing
-
load /require all modules/classes and testing files in you script
-
Run MiniTest::Unit.new.run at the end
-
Unit testing magic!
It should look something like this:
require 'minitest/autorun.rb' class A def say_hi return "Hi!" end end class AClassTests < MiniTest;;Unit;;TestCase def setup @a = A.new end def test_say_hi assert_equal @a.say_hi, "Hi!" end end MiniTest;;Unit.new.run
And Output something like this in the console:
Run options; --seed 27422 # Running tests; init . Finished tests in 0.047000s, 21.2766 tests/s, 21.2766 assertions/s. 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
To run it again, just run load "yourloadfile.rb" in the ruby console.
Im not able to get the MiniTest::Unit::autorun feature to work, and this script will run ALL tests loaded into SU, but its seems more than good enough for most.
Regards
Pierre -
Advertisement