1

I'm using headless watir-webdriver together with MiniTest for browser testing. That works fine. However there's something that doesn't satisfy me. I load the headless browser again and again before each test. I would prefer loading it once and using it all the time.

Is it possible to do so?

Here's a short example:

require 'watir-webdriver'
require 'headless'
require 'minitest/autorun'

class TestMe < MiniTest::Test

  def setup
    $headless = Headless.new
    $headless.start
    $b = Watir::Browser.new :firefox
    $b.goto  'http://www.google.com'
    puts "Browser loaded"
  end

  def teardown
    $b.close
    $headless.destroy
  end

  def test_that_page_is_google
    assert_equal "Google", $b.title
  end

  def test_something
    assert ( $b.span(:id => 'gbqfsa').exists?), ">>Fail Google search button exists"
  end

end

You'll see that "Browser loaded" is printed twice.

Any idea is welcome, thanks!

mikael-s
  • 310
  • 2
  • 12

1 Answers1

0

The setup and teardown methods run before and after each test in MiniTest. What you are looking for is something that runs before and after the entire suite of tests.

Check out the answers here: Before/After Suite when using Ruby MiniTest

Community
  • 1
  • 1
titusfortner
  • 4,099
  • 2
  • 15
  • 29