Reputation: 129
This is my code
class TestLogin < MiniTest::Test
def setup
@driver=Selenium::WebDriver.for :firefox
@driver.manage.window.maximize
@driver.navigate.to "http://google.com"
end
def test_case1
puts "testcase1"
end
def test_case2
puts "testcase2"
end
end
I want to run setup method only once for two testcases at the starting.
Upvotes: 4
Views: 2507
Reputation: 6027
You can use minitest-hooks
gem with before_all
something like:
require "minitest/autorun"
require 'minitest/hooks/test'
class TestLogin < MiniTest::Test
include Minitest::Hooks
def before_all
puts "setup .."
end
def test_case1
puts "testcase1"
end
def test_case2
puts "testcase2"
end
end
Now when you run the test you should see something like:
Run options: --seed 58346
# Running:
setup ..
testcase1
.testcase2
.
Finished in 0.001259s, 1588.7504 runs/s, 0.0000 assertions/s.
2 runs, 0 assertions, 0 failures, 0 errors, 0 skips
Upvotes: 5