Minitest-funcarg is a project mainly written in Ruby, it's free.
Proof of concept showing funcargs (style of DI) in minitest.
This is an extension to minitest which adds the ability to use funcargs as a method of test-level isolation. Funcargs are a form of dependency injection.
WARNING: This is a proof of concept. It works, but is not intended -- in its current form -- to be used for production tests.
Define a test class:
require "minitest/autorun"
require "minitest/unit"
require "minitest/funcarg"
class MyTest < MiniTest::Unit::TestCase
def minitest_funcarg__number
return 7
end
def test_things(number)
assert number > 0
end
end
Run them:
$ ruby my_test.rb
Started
.
Finished in 0.000343 seconds.
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
The result is that the number
parameter for test_things
was given
as the number 7 since that is what the magic method
minitest_funcarg__number
returned.