Hi folks,

as an addendum, this problem is preset for me because I'm using
minitest/autorun. I wanted to use this because of the various hooks that
are provided (def setup() etc); if you can think of a way to provide the
same pre-test hooks without being tied in to autorun, I could use that
instead.

Jams

On Thu, Mar 7, 2013 at 4:02 PM, James Harrison <jam / jamandbees.net> wrote:

> 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
>