From: James Harrison Date: 2013-03-08T08:02:09+09:00 Subject: Cannot Use Initialize With Minitest? --e89a8f22c5bd1d4abf04d75db23b Content-Type: text/plain; charset=ISO-8859-1 Hey folks, I've been trying my best to write a class that uses initialize() with minitest, so that I can swap out a specific dependency at runtime. It appears, though, that I cannot use initialize() in a class that inherits from minitest: ##### require "minitest/autorun" #A simple dependency which is being dispatched to. class Dependency def initialize(argument) $stderr.puts argument end end #The main test class. class TestProblemReproduction < MiniTest::Unit::TestCase def initialize(test_argument) Dependency.new(test_argument) end def test_something puts "This is here so minitest does something." end end TestProblemReproduction.new("stuff") ####### Expected Output is to see the class Dependency output "stuff". The actual output is that the class Dependency outputs "stuff\ntest_something" However, I have a use case where I would like to use minitest to run my test cases, but I have a bunch of tests written in selenium. With one flag, the selenium browser will be constructed to run locally on my desktop, for local testing. With a different flag, the selenium browser is constructed to run remotely on a set of remote test servers. Is there any way I can hand a dependency into my minitest based test cases? Or do they have to be static? Thanks! Jams --e89a8f22c5bd1d4abf04d75db23b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hey folks,

I've been trying my best to write a class= that uses initialize() with minitest, so that I can swap out a specific de= pendency at runtime. It appears, though, that I cannot use initialize() in = a class that inherits from minitest:

#####
require "minitest/autorun&quo= t;

#A simple dependency which is being dispatched = to.
class Dependency
=A0 def initialize(argument)
=A0 =A0 $stderr.puts argument
=A0 end
end

#The main test class.=A0
class TestProblemReprod= uction < MiniTest::Unit::TestCase
=A0 def initialize(test_argu= ment)
=A0 =A0 Dependency.new(test_argument)
=A0 end

=
=A0 def test_something
=A0 =A0 puts "This is here= so minitest does something."
=A0 end
end


TestProblemReproduction.new("stuff")

#######

Expected Outpu= t is to see the class Dependency output "stuff".
The ac= tual output is that the class Dependency outputs "stuff\ntest_somethin= g"


However, I have a use case where I= would like to use minitest to run my test cases, but I have a bunch of tes= ts written in selenium. With one flag, the selenium browser will be constru= cted to run locally on my desktop, for local testing. With a different flag= , the selenium browser is constructed to run remotely on a set of remote te= st servers.

Is there any way I can hand a dependency into my minite= st based test cases? Or do they have to be static?

Thanks!

Jams
--e89a8f22c5bd1d4abf04d75db23b--