testingbot 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/LICENSE +1 -1
- data/README.md +137 -0
- data/bin/testingbot +4 -3
- data/lib/testingbot.rb +1 -5
- data/lib/testingbot/api.rb +91 -15
- data/lib/testingbot/version.rb +1 -1
- data/spec/integration/api_spec.rb +21 -15
- data/spec/spec_helper.rb +6 -3
- data/testingbot.gemspec +3 -3
- metadata +7 -52
- data/README.rdoc +0 -237
- data/examples/android.rb +0 -14
- data/examples/capybara.rb +0 -22
- data/examples/capybara_multiple_browsers.rb +0 -38
- data/examples/cucumber/README.rdoc +0 -15
- data/examples/cucumber/Rakefile +0 -20
- data/examples/cucumber/features/support/env.rb +0 -13
- data/examples/cucumber/features/youtube.feature +0 -10
- data/examples/cucumber/features/youtube_steps.rb +0 -15
- data/examples/test_rspec.rb +0 -17
- data/examples/test_rspec1.rb +0 -36
- data/examples/test_unit.rb +0 -30
- data/lib/testingbot/capybara.rb +0 -66
- data/lib/testingbot/config.rb +0 -125
- data/lib/testingbot/cucumber.rb +0 -35
- data/lib/testingbot/hooks.rb +0 -284
- data/lib/testingbot/jasmine.rb +0 -29
- data/lib/testingbot/jasmine/README.rdoc +0 -16
- data/lib/testingbot/jasmine/Rakefile +0 -35
- data/lib/testingbot/jasmine/public/javascripts/Player.js +0 -22
- data/lib/testingbot/jasmine/public/javascripts/Song.js +0 -7
- data/lib/testingbot/jasmine/runner.rb +0 -4
- data/lib/testingbot/jasmine/spec/javascripts/PlayerSpec.js +0 -58
- data/lib/testingbot/jasmine/spec/javascripts/helpers/SpecHelper.js +0 -9
- data/lib/testingbot/jasmine/spec/javascripts/support/jasmine.yml +0 -73
- data/lib/testingbot/jasmine/test/Rakefile +0 -9
- data/lib/testingbot/jasmine/test/public/javascripts/Player.js +0 -22
- data/lib/testingbot/jasmine/test/public/javascripts/Song.js +0 -7
- data/lib/testingbot/jasmine/test/spec/javascripts/PlayerSpec.js +0 -58
- data/lib/testingbot/jasmine/test/spec/javascripts/helpers/SpecHelper.js +0 -9
- data/lib/testingbot/jasmine/test/spec/javascripts/support/jasmine.yml +0 -73
- data/lib/testingbot/selenium.rb +0 -127
- data/lib/testingbot/tunnel.rb +0 -104
- data/spec/integration/selenium1_spec.rb +0 -53
- data/spec/integration/selenium2_spec.rb +0 -60
- data/spec/integration/tunnel_spec.rb +0 -84
- data/spec/unit/api_spec.rb +0 -17
- data/spec/unit/config_spec.rb +0 -73
- data/spec/unit/tunnel_spec.rb +0 -41
- data/vendor/Testingbot-Tunnel.jar +0 -0
data/examples/cucumber/Rakefile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'cucumber/rake/task'
|
5
|
-
require 'selenium/rake/tasks'
|
6
|
-
|
7
|
-
task :cucumber do
|
8
|
-
browsers = [{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 10, :platform => "WINDOWS" }]
|
9
|
-
|
10
|
-
browsers.each do |browser|
|
11
|
-
ENV['SELENIUM_BROWSERNAME'] = browser[:browserName]
|
12
|
-
ENV['SELENIUM_BROWSERVERSION'] = browser[:version].to_s
|
13
|
-
ENV['SELENIUM_BROWSERPLATFORM'] = browser[:platform]
|
14
|
-
Rake::Task[:run_cucumber].execute(browser)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Cucumber::Rake::Task.new(:run_cucumber) do |t|
|
19
|
-
t.cucumber_opts = ["features"]
|
20
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'capybara'
|
2
|
-
require 'capybara/cucumber'
|
3
|
-
require 'rspec'
|
4
|
-
require 'selenium/webdriver'
|
5
|
-
require 'testingbot/cucumber'
|
6
|
-
|
7
|
-
unless ENV['SELENIUM_BROWSERNAME'].nil?
|
8
|
-
TestingBot::config do |config|
|
9
|
-
config[:desired_capabilities] = { :browserName => ENV['SELENIUM_BROWSERNAME'], :version => ENV['SELENIUM_BROWSERVERSION'], :platform => ENV['SELENIUM_BROWSERPLATFORM'] }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
Capybara.default_driver = :testingbot
|
@@ -1,10 +0,0 @@
|
|
1
|
-
@selenium
|
2
|
-
Feature: YouTube has a search function.
|
3
|
-
|
4
|
-
Background:
|
5
|
-
Given I am on YouTube
|
6
|
-
|
7
|
-
Scenario: Search for a term
|
8
|
-
When I fill in "search_query" with "text adventure"
|
9
|
-
And I press "search-btn"
|
10
|
-
Then I should see "GET LAMP: The Text Adventure Documentary"
|
@@ -1,15 +0,0 @@
|
|
1
|
-
Given /^I am on (.+)$/ do |url|
|
2
|
-
visit "http://www.youtube.com"
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
6
|
-
fill_in(field, :with => value)
|
7
|
-
end
|
8
|
-
|
9
|
-
When /^I press "([^"]*)"$/ do |button|
|
10
|
-
click_button(button)
|
11
|
-
end
|
12
|
-
|
13
|
-
Then /^I should see "([^"]*)"$/ do |text|
|
14
|
-
page.should have_content(text)
|
15
|
-
end
|
data/examples/test_rspec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require "selenium/client"
|
3
|
-
require 'rspec'
|
4
|
-
require 'testingbot'
|
5
|
-
require 'testingbot/tunnel'
|
6
|
-
|
7
|
-
TestingBot::config do |config|
|
8
|
-
config[:desired_capabilities] = [{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 11, :platform => "WINDOWS" }]
|
9
|
-
end
|
10
|
-
|
11
|
-
# rspec 2
|
12
|
-
describe "People", :type => :selenium, :multibrowser => true do
|
13
|
-
it "can find the right title" do
|
14
|
-
page.navigate.to "http://www.google.com"
|
15
|
-
page.title.should eql("Google")
|
16
|
-
end
|
17
|
-
end
|
data/examples/test_rspec1.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
gem "rspec", "<2"
|
3
|
-
gem "selenium-client"
|
4
|
-
require "selenium/client"
|
5
|
-
require "selenium/rspec/spec_helper"
|
6
|
-
gem "testingbot"
|
7
|
-
require "testingbot"
|
8
|
-
|
9
|
-
describe "People" do
|
10
|
-
attr_reader :selenium_driver
|
11
|
-
alias :page :selenium_driver
|
12
|
-
|
13
|
-
before(:all) do
|
14
|
-
@selenium_driver = Selenium::Client::Driver.new \
|
15
|
-
:host => "hub.testingbot.com",
|
16
|
-
:port => 4444,
|
17
|
-
:browser => "firefox",
|
18
|
-
:url => "http://www.google.com",
|
19
|
-
:timeout_in_second => 60,
|
20
|
-
:platform => "WINDOWS",
|
21
|
-
:version => "10"
|
22
|
-
end
|
23
|
-
|
24
|
-
before(:each) do
|
25
|
-
@selenium_driver.start_new_browser_session
|
26
|
-
end
|
27
|
-
|
28
|
-
append_after(:each) do
|
29
|
-
@selenium_driver.close_current_browser_session
|
30
|
-
end
|
31
|
-
|
32
|
-
it "can find the right title" do
|
33
|
-
page.open "/"
|
34
|
-
page.title.should eql("Google")
|
35
|
-
end
|
36
|
-
end
|
data/examples/test_unit.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
require "selenium/client"
|
4
|
-
require 'testingbot'
|
5
|
-
|
6
|
-
class ExampleTest < TestingBot::TestCase
|
7
|
-
attr_reader :browser
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@browser = Selenium::Client::Driver.new \
|
11
|
-
:host => "hub.testingbot.com",
|
12
|
-
:port => 4444,
|
13
|
-
:browser => "firefox",
|
14
|
-
:platform => "WINDOWS",
|
15
|
-
:version => "10",
|
16
|
-
:url => "http://www.google.com",
|
17
|
-
:timeout_in_second => 60
|
18
|
-
|
19
|
-
browser.start_new_browser_session
|
20
|
-
end
|
21
|
-
|
22
|
-
def teardown
|
23
|
-
browser.close_current_browser_session
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_page_search
|
27
|
-
browser.open "/"
|
28
|
-
assert_equal "Google", browser.title
|
29
|
-
end
|
30
|
-
end
|
data/lib/testingbot/capybara.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'capybara'
|
2
|
-
require 'testingbot/config'
|
3
|
-
require 'testingbot/tunnel'
|
4
|
-
require 'testingbot/selenium'
|
5
|
-
require 'capybara/dsl'
|
6
|
-
|
7
|
-
@tunnel = nil
|
8
|
-
|
9
|
-
module TestingBot
|
10
|
-
module Capybara
|
11
|
-
|
12
|
-
def self.start_tunnel
|
13
|
-
return @tunnel unless @tunnel.nil?
|
14
|
-
|
15
|
-
@tunnel = TestingBot::Tunnel.new(TestingBot.get_config[:tunnel_options] || {})
|
16
|
-
@tunnel.start
|
17
|
-
end
|
18
|
-
|
19
|
-
class CustomDriver < ::Capybara::Selenium::Driver
|
20
|
-
|
21
|
-
def session_id
|
22
|
-
@browser.session_id
|
23
|
-
end
|
24
|
-
|
25
|
-
def browser
|
26
|
-
unless @browser
|
27
|
-
if TestingBot.get_config[:require_tunnel]
|
28
|
-
TestingBot::Capybara.start_tunnel
|
29
|
-
end
|
30
|
-
|
31
|
-
@browser = TestingBot::SeleniumWebdriver.new(@options || {})
|
32
|
-
|
33
|
-
main = Process.pid
|
34
|
-
at_exit do
|
35
|
-
if @browser
|
36
|
-
begin
|
37
|
-
@browser.quit
|
38
|
-
rescue
|
39
|
-
end
|
40
|
-
end
|
41
|
-
if TestingBot.get_config[:require_tunnel]
|
42
|
-
@tunnel.stop unless @tunnel.nil?
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
@browser
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
module Capybara
|
53
|
-
class Session
|
54
|
-
def stop
|
55
|
-
driver.quit
|
56
|
-
end
|
57
|
-
|
58
|
-
def session_id
|
59
|
-
driver.session_id
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
Capybara.register_driver :testingbot do |app|
|
65
|
-
TestingBot::Capybara::CustomDriver.new(app)
|
66
|
-
end
|
data/lib/testingbot/config.rb
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
module TestingBot
|
2
|
-
@@config = nil
|
3
|
-
def self.get_config
|
4
|
-
@@config = TestingBot::Config.new if @@config.nil?
|
5
|
-
@@config
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.reset_config!
|
9
|
-
@@config = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.config
|
13
|
-
yield self.get_config
|
14
|
-
end
|
15
|
-
|
16
|
-
class Config
|
17
|
-
|
18
|
-
attr_reader :options
|
19
|
-
|
20
|
-
def initialize(options = {})
|
21
|
-
@options = default_options
|
22
|
-
@options = @options.merge(load_config_file)
|
23
|
-
@options = @options.merge(load_config_environment)
|
24
|
-
@options = @options.merge(options)
|
25
|
-
end
|
26
|
-
|
27
|
-
def [](key)
|
28
|
-
@options[key]
|
29
|
-
end
|
30
|
-
|
31
|
-
def add_options(options = {})
|
32
|
-
@options = @options.merge(options)
|
33
|
-
end
|
34
|
-
|
35
|
-
def []=(key, value)
|
36
|
-
@options[key] = value
|
37
|
-
end
|
38
|
-
|
39
|
-
def options
|
40
|
-
@options
|
41
|
-
end
|
42
|
-
|
43
|
-
def require_tunnel(host = "127.0.0.1", port = 4445)
|
44
|
-
@options[:require_tunnel] = true
|
45
|
-
@options[:host] = host
|
46
|
-
@options[:port] = port
|
47
|
-
end
|
48
|
-
|
49
|
-
def client_key
|
50
|
-
@options[:client_key]
|
51
|
-
end
|
52
|
-
|
53
|
-
def client_secret
|
54
|
-
@options[:client_secret]
|
55
|
-
end
|
56
|
-
|
57
|
-
def desired_capabilities
|
58
|
-
# check if instance of Selenium::WebDriver::Remote::Capabilities
|
59
|
-
unless @options[:desired_capabilities].instance_of?(Hash) || @options[:desired_capabilities].instance_of?(Array)
|
60
|
-
return symbolize_keys @options[:desired_capabilities].as_json
|
61
|
-
end
|
62
|
-
@options[:desired_capabilities]
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def symbolize_keys(hash)
|
68
|
-
hash.inject({}) {|new_hash, key_value|
|
69
|
-
key, value = key_value
|
70
|
-
value = symbolize_keys(value) if value.is_a?(Hash)
|
71
|
-
new_hash[key.to_sym] = value
|
72
|
-
new_hash
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
|
-
def default_desired_capabilities
|
77
|
-
{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }
|
78
|
-
end
|
79
|
-
|
80
|
-
def default_options
|
81
|
-
{
|
82
|
-
:host => "hub.testingbot.com",
|
83
|
-
:port => 4444,
|
84
|
-
:jenkins_output => true,
|
85
|
-
:desired_capabilities => default_desired_capabilities
|
86
|
-
}
|
87
|
-
end
|
88
|
-
|
89
|
-
def load_config_file
|
90
|
-
options = {}
|
91
|
-
|
92
|
-
is_windows = false
|
93
|
-
|
94
|
-
begin
|
95
|
-
require 'rbconfig'
|
96
|
-
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
|
97
|
-
rescue
|
98
|
-
is_windows = (RUBY_PLATFORM =~ /w.*32/) || (ENV["OS"] && ENV["OS"] == "Windows_NT")
|
99
|
-
end
|
100
|
-
|
101
|
-
if is_windows
|
102
|
-
config_file = "#{ENV['HOMEDRIVE']}\\.testingbot"
|
103
|
-
else
|
104
|
-
config_file = File.expand_path("~/.testingbot")
|
105
|
-
end
|
106
|
-
|
107
|
-
if File.exists?(config_file)
|
108
|
-
str = File.open(config_file) { |f| f.readline }.chomp
|
109
|
-
options[:client_key], options[:client_secret] = str.split(':')
|
110
|
-
end
|
111
|
-
|
112
|
-
options
|
113
|
-
end
|
114
|
-
|
115
|
-
def load_config_environment
|
116
|
-
options = {}
|
117
|
-
options[:client_key] = ENV['TESTINGBOT_CLIENTKEY']
|
118
|
-
options[:client_secret] = ENV['TESTINGBOT_CLIENTSECRET']
|
119
|
-
|
120
|
-
options.delete_if { |key, value| value.nil?}
|
121
|
-
|
122
|
-
options
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
data/lib/testingbot/cucumber.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'testingbot/config'
|
2
|
-
require 'testingbot/capybara'
|
3
|
-
require 'testingbot/api'
|
4
|
-
|
5
|
-
if defined?(Cucumber)
|
6
|
-
Before('@selenium') do
|
7
|
-
::Capybara.current_driver = :testingbot
|
8
|
-
end
|
9
|
-
|
10
|
-
After('@selenium') do |scenario|
|
11
|
-
if !TestingBot.get_config[:client_key].nil?
|
12
|
-
begin
|
13
|
-
driver = ::Capybara.current_session.driver
|
14
|
-
if driver.browser.respond_to?(:session_id)
|
15
|
-
session_id = driver.browser.session_id
|
16
|
-
else
|
17
|
-
session_id = driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
|
18
|
-
end
|
19
|
-
|
20
|
-
api = TestingBot::Api.new
|
21
|
-
params = {
|
22
|
-
"session_id" => session_id,
|
23
|
-
"status_message" => (scenario.failed? ? scenario.exception.message : ""),
|
24
|
-
"success" => !scenario.failed? ? 1 : 0,
|
25
|
-
"name" => scenario.title,
|
26
|
-
"kind" => 2
|
27
|
-
}
|
28
|
-
|
29
|
-
data = api.update_test(session_id, params)
|
30
|
-
rescue Exception => e
|
31
|
-
p "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/testingbot/hooks.rb
DELETED
@@ -1,284 +0,0 @@
|
|
1
|
-
# rspec 1
|
2
|
-
if defined?(Spec) && defined?(Spec::VERSION::MAJOR) && Spec::VERSION::MAJOR == 1
|
3
|
-
require "selenium/rspec/spec_helper"
|
4
|
-
Spec::Runner.configure do |config|
|
5
|
-
config.before(:suite) do
|
6
|
-
if TestingBot.get_config[:require_tunnel]
|
7
|
-
@@tunnel = TestingBot::Tunnel.new(TestingBot.get_config[:tunnel_options] || {})
|
8
|
-
@@tunnel.start
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
config.after(:suite) do
|
13
|
-
@@tunnel.stop if defined? @@tunnel
|
14
|
-
end
|
15
|
-
|
16
|
-
config.prepend_after(:each) do
|
17
|
-
client_key = TestingBot.get_config[:client_key]
|
18
|
-
client_secret = TestingBot.get_config[:client_secret]
|
19
|
-
|
20
|
-
if !client_key.nil?
|
21
|
-
|
22
|
-
session_id = nil
|
23
|
-
|
24
|
-
if !@selenium_driver.nil?
|
25
|
-
session_id = @selenium_driver.session_id_backup
|
26
|
-
elsif defined?(Capybara)
|
27
|
-
begin
|
28
|
-
if page.driver.browser.respond_to?(:session_id)
|
29
|
-
session_id = page.driver.browser.session_id
|
30
|
-
else
|
31
|
-
session_id = page.driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
|
32
|
-
end
|
33
|
-
rescue Exception => e
|
34
|
-
puts "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
if !session_id.nil?
|
39
|
-
api = TestingBot::Api.new
|
40
|
-
params = {
|
41
|
-
"session_id" => session_id,
|
42
|
-
"status_message" => @execution_error,
|
43
|
-
"success" => !actual_failure? ? 1 : 0,
|
44
|
-
"name" => description.to_s
|
45
|
-
}
|
46
|
-
|
47
|
-
begin
|
48
|
-
data = api.update_test(session_id, params)
|
49
|
-
rescue
|
50
|
-
end
|
51
|
-
|
52
|
-
if ENV['JENKINS_HOME'] && (TestingBot.get_config[:jenkins_output] == true)
|
53
|
-
puts "TestingBotSessionID=" + session_id
|
54
|
-
end
|
55
|
-
end
|
56
|
-
else
|
57
|
-
puts "Can't post test results to TestingBot since I could not find a .testingbot file in your home-directory."
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# rspec 2
|
64
|
-
begin
|
65
|
-
require 'rspec'
|
66
|
-
|
67
|
-
::RSpec.configuration.before :suite do
|
68
|
-
if TestingBot.get_config[:require_tunnel]
|
69
|
-
@@tunnel = TestingBot::Tunnel.new(TestingBot.get_config[:tunnel_options] || {})
|
70
|
-
@@tunnel.start
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
module TestingBot
|
75
|
-
module RSpecInclude
|
76
|
-
attr_reader :selenium_driver
|
77
|
-
alias_method :page, :selenium_driver
|
78
|
-
|
79
|
-
def self.included(base)
|
80
|
-
base.around do |test|
|
81
|
-
if TestingBot.get_config.desired_capabilities.instance_of?(Array)
|
82
|
-
TestingBot.get_config.desired_capabilities.each do |browser|
|
83
|
-
|
84
|
-
if defined?(Capybara)
|
85
|
-
::Capybara.register_driver :multibrowser do |app|
|
86
|
-
TestingBot::Capybara::CustomDriver.new(app, { :desired_capabilities => browser })
|
87
|
-
end
|
88
|
-
|
89
|
-
@selenium_driver = ::Capybara::Session.new(:multibrowser)
|
90
|
-
else
|
91
|
-
@selenium_driver = TestingBot::SeleniumWebdriver.new({ :desired_capabilities => browser })
|
92
|
-
end
|
93
|
-
|
94
|
-
begin
|
95
|
-
test.run
|
96
|
-
ensure
|
97
|
-
@selenium_driver.stop
|
98
|
-
end
|
99
|
-
end
|
100
|
-
else
|
101
|
-
if defined?(Capybara)
|
102
|
-
@selenium_driver = ::Capybara::Session.new(:testingbot)
|
103
|
-
else
|
104
|
-
@selenium_driver = TestingBot::SeleniumWebdriver.new({ :desired_capabilities => TestingBot.get_config.desired_capabilities })
|
105
|
-
end
|
106
|
-
begin
|
107
|
-
test.run
|
108
|
-
ensure
|
109
|
-
@selenium_driver.stop
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
module RSpecIncludeLegacy
|
117
|
-
attr_reader :selenium_driver
|
118
|
-
alias_method :page, :selenium_driver
|
119
|
-
|
120
|
-
def self.included(base)
|
121
|
-
base.around do |test|
|
122
|
-
if TestingBot.get_config.desired_capabilities.instance_of?(Array)
|
123
|
-
TestingBot.get_config.desired_capabilities.each do |browser|
|
124
|
-
@selenium_driver = ::Selenium::Client::Driver.new(:browser => browser[:browserName], :url => TestingBot.get_config[:browserUrl])
|
125
|
-
@selenium_driver.start_new_browser_session(browser)
|
126
|
-
begin
|
127
|
-
test.run
|
128
|
-
ensure
|
129
|
-
@selenium_driver.stop
|
130
|
-
end
|
131
|
-
end
|
132
|
-
else
|
133
|
-
@selenium_driver = ::Selenium::Client::Driver.new(:browser => browser[:browserName], :url => TestingBot.get_config[:browserUrl])
|
134
|
-
@selenium_driver.start_new_browser_session(TestingBot.get_config.desired_capabilities)
|
135
|
-
begin
|
136
|
-
test.run
|
137
|
-
ensure
|
138
|
-
@selenium_driver.stop
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
::RSpec.configuration.include(TestingBot::RSpecIncludeLegacy, :multibrowserRC => true)
|
147
|
-
::RSpec.configuration.include(TestingBot::RSpecInclude, :multibrowser => true)
|
148
|
-
|
149
|
-
::RSpec.configuration.after :suite do
|
150
|
-
@@tunnel.stop if defined? @@tunnel
|
151
|
-
end
|
152
|
-
|
153
|
-
::RSpec.configuration.after :each do
|
154
|
-
client_key = TestingBot.get_config[:client_key]
|
155
|
-
client_secret = TestingBot.get_config[:client_secret]
|
156
|
-
|
157
|
-
if !client_key.nil?
|
158
|
-
test_name = ""
|
159
|
-
if example.metadata && example.metadata[:example_group]
|
160
|
-
if example.metadata[:example_group][:description_args]
|
161
|
-
test_name = example.metadata[:example_group][:description_args].join(" ")
|
162
|
-
end
|
163
|
-
|
164
|
-
if example.metadata[:description_args]
|
165
|
-
test_name = test_name + " it " + example.metadata[:description_args].join(" ")
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
status_message = ""
|
170
|
-
status_message = example.exception.to_s if !example.exception.nil?
|
171
|
-
|
172
|
-
session_id = nil
|
173
|
-
|
174
|
-
if !@selenium_driver.nil?
|
175
|
-
session_id = @selenium_driver.session_id
|
176
|
-
elsif defined? page
|
177
|
-
begin
|
178
|
-
if page.driver.browser.respond_to?(:session_id)
|
179
|
-
session_id = page.driver.browser.session_id
|
180
|
-
else
|
181
|
-
session_id = page.driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
|
182
|
-
end
|
183
|
-
rescue Exception => e
|
184
|
-
p "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
|
185
|
-
end
|
186
|
-
|
187
|
-
if session_id.nil? || session_id.empty?
|
188
|
-
begin
|
189
|
-
session_id = page.driver.browser.send(:bridge).session_id
|
190
|
-
rescue
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
if !session_id.nil?
|
196
|
-
if ENV['JENKINS_HOME'] && (TestingBot.get_config[:jenkins_output] == true)
|
197
|
-
puts "TestingBotSessionID=" + session_id
|
198
|
-
end
|
199
|
-
api = TestingBot::Api.new
|
200
|
-
params = {
|
201
|
-
"session_id" => session_id,
|
202
|
-
"status_message" => status_message,
|
203
|
-
"success" => example.exception.nil? ? 1 : 0,
|
204
|
-
"name" => test_name
|
205
|
-
}
|
206
|
-
|
207
|
-
begin
|
208
|
-
data = api.update_test(session_id, params)
|
209
|
-
rescue
|
210
|
-
end
|
211
|
-
end
|
212
|
-
else
|
213
|
-
puts "Can't post test results to TestingBot since I could not find a .testingbot file in your home-directory."
|
214
|
-
end
|
215
|
-
end
|
216
|
-
rescue LoadError
|
217
|
-
end
|
218
|
-
|
219
|
-
module TestingBot
|
220
|
-
module SeleniumForTestUnit
|
221
|
-
attr_accessor :exception
|
222
|
-
attr_reader :browser
|
223
|
-
|
224
|
-
def run(*args, &blk)
|
225
|
-
return if @method_name.to_s == "default_test"
|
226
|
-
if TestingBot.get_config.desired_capabilities.instance_of?(Array)
|
227
|
-
TestingBot.get_config.desired_capabilities.each do |browser|
|
228
|
-
@browser = ::Selenium::Client::Driver.new(:browser => browser[:browserName], :url => TestingBot.get_config[:browserUrl])
|
229
|
-
@browser.start_new_browser_session(browser)
|
230
|
-
super(*args, &blk)
|
231
|
-
@browser.stop
|
232
|
-
end
|
233
|
-
else
|
234
|
-
super(*args, &blk)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
def teardown
|
239
|
-
return super if @browser.nil?
|
240
|
-
api = TestingBot::Api.new
|
241
|
-
params = {
|
242
|
-
"session_id" => @browser.session_id,
|
243
|
-
"status_message" => @exception || "",
|
244
|
-
"success" => passed? ? 1 : 0,
|
245
|
-
"name" => self.to_s
|
246
|
-
}
|
247
|
-
|
248
|
-
begin
|
249
|
-
data = api.update_test(@browser.session_id, params)
|
250
|
-
rescue
|
251
|
-
end
|
252
|
-
|
253
|
-
if ENV['JENKINS_HOME'] && (TestingBot.get_config[:jenkins_output] == true)
|
254
|
-
puts "TestingBotSessionID=" + @browser.session_id
|
255
|
-
end
|
256
|
-
super
|
257
|
-
end
|
258
|
-
|
259
|
-
def handle_exception(e)
|
260
|
-
@exception = e.to_s
|
261
|
-
problem_occurred
|
262
|
-
end
|
263
|
-
|
264
|
-
alias :handle_exception_old :handle_exception
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
begin
|
269
|
-
require 'test/unit/testcase'
|
270
|
-
module TestingBot
|
271
|
-
class TestCase < Test::Unit::TestCase
|
272
|
-
include SeleniumForTestUnit
|
273
|
-
end
|
274
|
-
end
|
275
|
-
rescue LoadError
|
276
|
-
end
|
277
|
-
|
278
|
-
if defined?(ActiveSupport::TestCase)
|
279
|
-
module TestingBot
|
280
|
-
class RailsTestCase < ::ActiveSupport::TestCase
|
281
|
-
include SeleniumForTestUnit
|
282
|
-
end
|
283
|
-
end
|
284
|
-
end
|