forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
speed up selenium by not doing setup/teardown after every set of specs
Change-Id: I735c8a55f0c141b4843b187fd817eda21000d34b Reviewed-on: https://gerrit.instructure.com/4733 Tested-by: Hudson <[email protected]> Tested-by: Selenium <[email protected]> Reviewed-by: Zach Wily <[email protected]>
- Loading branch information
1 parent
b4116e5
commit 823cb75
Showing
3 changed files
with
16 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,10 @@ | |
$server_port = nil | ||
$app_host_and_port = nil | ||
|
||
at_exit do | ||
$selenium_driver.try(:quit) | ||
end | ||
|
||
module SeleniumTestsHelperMethods | ||
def setup_selenium | ||
if SELENIUM_CONFIG[:host] && SELENIUM_CONFIG[:port] && !SELENIUM_CONFIG[:host_and_port] | ||
|
@@ -166,9 +170,9 @@ def self.start_forked_webrick_server | |
include SeleniumTestsHelperMethods | ||
include CustomSeleniumRspecMatchers | ||
|
||
attr_reader :selenium_driver | ||
def selenium_driver; $selenium_driver; end | ||
alias_method :driver, :selenium_driver | ||
|
||
def login_as(username = "[email protected]", password = "asdfasdf") | ||
# log out (just in case) | ||
driver.navigate.to(app_host + '/logout') | ||
|
@@ -304,12 +308,7 @@ def make_full_screen | |
end | ||
|
||
append_before(:all) do | ||
@selenium_driver = setup_selenium | ||
end | ||
|
||
append_after(:all) do | ||
@webserver_shutdown.call | ||
@selenium_driver.quit | ||
$selenium_driver ||= setup_selenium | ||
end | ||
|
||
append_before(:all) do | ||
|
@@ -328,13 +327,19 @@ def make_full_screen | |
shared_examples_for "in-process server selenium tests" do | ||
it_should_behave_like "all selenium tests" | ||
prepend_before(:all) do | ||
@webserver_shutdown = SeleniumTestsHelperMethods.start_in_process_webrick_server | ||
$in_proc_webserver_shutdown ||= SeleniumTestsHelperMethods.start_in_process_webrick_server | ||
end | ||
end | ||
|
||
shared_examples_for "forked server selenium tests" do | ||
it_should_behave_like "all selenium tests" | ||
prepend_before(:all) do | ||
@webserver_shutdown = SeleniumTestsHelperMethods.start_forked_webrick_server | ||
$in_proc_webserver_shutdown.try(:call) | ||
$in_proc_webserver_shutdown = nil | ||
@forked_webserver_shutdown = SeleniumTestsHelperMethods.start_forked_webrick_server | ||
end | ||
|
||
append_after(:all) do | ||
@forked_webserver_shutdown.call | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
--colour | ||
--format progress | ||
--format html:tmp/spec_html/index.html | ||
--loadby mtime | ||
--reverse |