I want to call def setup method before all tests in minitest ruby -


this 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 run setup method once 2 testcases @ starting.

you can use minitest-hooks gem before_all 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 run test should see 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 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -