Added improved file structure to tests

This commit is contained in:
Wade Alcorn
2012-01-13 21:39:04 +10:00
parent bd09e1ffdb
commit 0f43ba6036
3 changed files with 18 additions and 12 deletions

10
test/common/beef_test.rb Normal file
View File

@@ -0,0 +1,10 @@
require 'test/unit'
class BeefTest
def self.save_screenshot(session)
Dir.mkdir(BEEF_TEST_DIR) if not File.directory?(BEEF_TEST_DIR)
session.driver.browser.save_screenshot(BEEF_TEST_DIR + Time.now.strftime("%Y-%m-%d--%H-%M-%S-%N") + ".png")
end
end

View File

@@ -0,0 +1 @@
BEEF_TEST_DIR = "/tmp/beef-test/"

View File

@@ -1,25 +1,20 @@
require 'test/unit'
BEEF_TEST_DIR = "/tmp/beef-test/"
require '../common/test_constants'
require '../common/beef_test'
class TC_login < Test::Unit::TestCase
def save_screenshot(session)
Dir.mkdir(BEEF_TEST_DIR) if not File.directory?(BEEF_TEST_DIR)
session.driver.browser.save_screenshot(BEEF_TEST_DIR + Time.now.strftime("%Y-%m-%d--%H-%M-%S-%N") + ".png")
end
def test_log_in
session = Capybara::Session.new(:selenium)
session.visit('http://localhost:3000/ui/panel')
save_screenshot(session)
BeefTest.save_screenshot(session)
session.has_content?('BeEF Authentication')
session.fill_in 'user', :with => 'beef'
session.fill_in 'pass', :with => 'beef'
save_screenshot(session)
BeefTest.save_screenshot(session)
session.click_button('Login')
session.has_content?('logout')
save_screenshot(session)
BeefTest.save_screenshot(session)
session
end
@@ -28,9 +23,9 @@ class TC_login < Test::Unit::TestCase
session = test_log_in
session.has_content?('logout')
session.click_link('Logout')
save_screenshot(session)
BeefTest.save_screenshot(session)
session.has_content?('BeEF Authentication')
save_screenshot(session)
BeefTest.save_screenshot(session)
session
end