Minitest, parallelize_me! and the setup() method

I’m a bit confused on the execution of setup() in the context of
parallelized unit tests. Let’s assume this test class:

require ‘minitest/unit’
require ‘minitest/autorun’

class MyTest < MiniTest::Unit::TestCase

parallelize_me!

def setup

end

def test_one

end

def test_two

end

end

According to the docs, setup “… runs before every test”. This means
that setup is run before test_one and again before test_two, right? This
means that setup() must be written in a way that it can be run in
parallel.

Now assume that I want to do some initialization, which should be done
before all the tests are started (creating directories, for example).
This can not go into ‘setup’. Do I have to do such “general
initialization” tasks outside of the runner, or can I express it within
the test class too?

hi what you are asking is possible in Test-Unit, Why not you go for
Test-unit?

require ‘test-unit’

class MyTest<Test::Unit::TestCase
class<<self
def startup
puts ‘This would be executed only once before all the testcases’
end

def shutdown
  puts 'this would be executed only once after the completion of all

the testcases’
end
end

def setup
puts ‘this would be execute before each testcases’
end

def teardown
puts ‘this would be executed after each testcases’
end

def test_1
puts ‘first testcase’
end

def test_2
puts ‘second testcases’
end

end


There are some other 'setup’and ‘cleanup’ also can be added, If you want
to know, Just let me know.

Thanks a lot for the clarification. This is then likely what I have to
do. I have used Minitest, because my understanding was that this was
kind of the successor of Test::Unit, but it seems that both have their
merits…

hi Ronald F.,

I had the similar thoughts like you regarding to minitest, but it’s not,
the higher version of test-unit has added more flexibility and in my
company i am running my entire project using this test-unit, it works
pretty fine.