browserstack-cucumber 0.2 → 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +4 -0
- data/lib/browserstack.rb +3 -3
- data/lib/browserstack/browserstack.rb +24 -6
- data/lib/browserstack/jenkins_formatter.rb +3 -2
- data/lib/browserstack/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2QyOWE3ZTY1YThhZTViNDg1ZjhhZDYxYzk4ZDU4ZmZlMmY4YzU4Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGZkYmE5ZTc1MmMzNmYyMzE1YmQzYjYxNTZkYjM3Mjc5NWI5Zjg3NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWQ1NDQyZGYxM2MwZTA2NzRkMjU2MjY5ODQ0NDcyYWZhOTdmZmFlZDg2ZmY2
|
10
|
+
YzRhNzJjN2JlNDNkMzcyZGQ2MzZkN2NjYWViOWZhMDg2OTIzMzIwNWZmZjQ3
|
11
|
+
OTUxM2Y1MzdlZDU3MGUwYzYwOGFjYzhiMWE3ZTBiNzM1Yzc2OTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2M5Yjg1M2IyZDJjOTMwNjJmYjlmMjUxNDViN2E4OWM1ZTUzY2RiNzlhNDEw
|
14
|
+
YTQ3ZGQxNjA5OGEwNDEyZDk3NjIzZDUzYmFlZWViNTYzM2NlNzA1MzExZTRi
|
15
|
+
YTM1ODlhYjY0MjY0ZmVlODRmNTU2ZWJiMGI1ODBlMjVhMTU0ZjY=
|
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
A Ruby helper for running tests in BrowserStack Automate browser testing cloud service.
|
4
4
|
|
5
|
+
Marks BrowserStack Automate sessions as failed when cucumber scenario fails.
|
6
|
+
|
7
|
+
This GEM includes custom Cucumber formatter to generate Junit report files accepted by Jenkins. These Junit reports includes BrowserStack session URL for failed scenarios.
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
data/lib/browserstack.rb
CHANGED
@@ -7,9 +7,9 @@ require 'browserstack/jenkins_formatter'
|
|
7
7
|
# formatter can be used with --format browserstack_jenkins
|
8
8
|
require 'cucumber/cli/main'
|
9
9
|
|
10
|
-
Cucumber::Cli::Options::BUILTIN_FORMATS[
|
11
|
-
|
12
|
-
|
10
|
+
Cucumber::Cli::Options::BUILTIN_FORMATS['browserstack_jenkins'] = [
|
11
|
+
'BrowserStackCucumber::JenkinsFormatter',
|
12
|
+
'BrowserStack Jenkins JUnit report formatter'
|
13
13
|
]
|
14
14
|
|
15
15
|
|
@@ -86,6 +86,7 @@ module BrowserStackCucumber
|
|
86
86
|
capabilities['project'] = ENV['JOB_NAME']
|
87
87
|
capabilities
|
88
88
|
end
|
89
|
+
|
89
90
|
def self.url
|
90
91
|
'http://hub.browserstack.com/wd/hub'
|
91
92
|
end
|
@@ -111,7 +112,7 @@ module BrowserStackCucumber
|
|
111
112
|
@browser.get @test_url
|
112
113
|
raise "Network connection issue. Failed to open #{@test_url} and find '#{@test_substring}' substring" if !@browser.page_source.downcase.include? @test_substring
|
113
114
|
@browser
|
114
|
-
rescue =>e
|
115
|
+
rescue => e
|
115
116
|
if e.message.include? 'sessions are currently being used. Please upgrade to add more parallel sessions'
|
116
117
|
puts "Run out of sessions: '#{e.message}'"
|
117
118
|
else
|
@@ -145,7 +146,7 @@ module BrowserStackCucumber
|
|
145
146
|
def self.session_url
|
146
147
|
@session_url = get_session_info(@browser.session_id)
|
147
148
|
@session_url['automation_session']['browser_url']
|
148
|
-
rescue =>e
|
149
|
+
rescue => e
|
149
150
|
return "failed to obtain session url #{e}"
|
150
151
|
end
|
151
152
|
|
@@ -155,7 +156,7 @@ module BrowserStackCucumber
|
|
155
156
|
puts "no free BrowserStack session available now#{parsed_r}" if (parsed_r['sessions_limit']==parsed_r['running_sessions'])
|
156
157
|
parsed_r['sessions_limit']-parsed_r['running_sessions']>0
|
157
158
|
end
|
158
|
-
rescue RestClient::Unauthorized=>e
|
159
|
+
rescue RestClient::Unauthorized => e
|
159
160
|
puts "Error: Failed to access BrowserStack account, please check username and api key: #{e}"
|
160
161
|
raise
|
161
162
|
end
|
@@ -163,19 +164,33 @@ module BrowserStackCucumber
|
|
163
164
|
def self.get_session_limits
|
164
165
|
url = "https://#{selenium_username}:#{selenium_apikey}@api.browserstack.com/3/status"
|
165
166
|
r = RestClient.get(url)
|
166
|
-
|
167
|
+
JSON.parse(r.body)
|
167
168
|
end
|
168
169
|
|
169
170
|
def self.call_api(url_part)
|
170
171
|
url = "https://#{selenium_username}:#{selenium_apikey}@www.browserstack.com/automate/#{url_part}"
|
171
172
|
r = RestClient.get(url)
|
172
|
-
|
173
|
+
JSON.parse(r.body)
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.put_api(url_part, payload)
|
177
|
+
url = "https://#{selenium_username}:#{selenium_apikey}@www.browserstack.com/automate/#{url_part}"
|
178
|
+
r = RestClient.put(url, payload.to_json, :content_type => :json)
|
179
|
+
JSON.parse(r.body)
|
173
180
|
end
|
174
181
|
|
182
|
+
|
175
183
|
def self.get_session_info(session_id)
|
176
184
|
call_api("sessions/#{session_id}.json")
|
177
185
|
end
|
178
186
|
|
187
|
+
def self.update_session_status(success)
|
188
|
+
unless success
|
189
|
+
put_api("sessions/#{@last_session_id}.json", {'status' => 'error'})
|
190
|
+
end
|
191
|
+
rescue => e
|
192
|
+
puts e
|
193
|
+
end
|
179
194
|
|
180
195
|
def self.browser
|
181
196
|
@browser
|
@@ -199,6 +214,7 @@ module BrowserStackCucumber
|
|
199
214
|
|
200
215
|
|
201
216
|
module_function
|
217
|
+
|
202
218
|
def before_hook_impl
|
203
219
|
#::Capybara.default_driver = :browser_stack
|
204
220
|
#::Capybara.current_driver = :browser_stack
|
@@ -206,6 +222,7 @@ module BrowserStackCucumber
|
|
206
222
|
end
|
207
223
|
|
208
224
|
module_function
|
225
|
+
|
209
226
|
def around_hook_impl(scenario, block)
|
210
227
|
#::Capybara.current_driver = :browser_stack
|
211
228
|
|
@@ -236,12 +253,13 @@ module BrowserStackCucumber
|
|
236
253
|
# job.passed = !scenario.failed?
|
237
254
|
# job.save
|
238
255
|
#end
|
239
|
-
|
256
|
+
BrowserStackCucumber::Config.update_session_status(!scenario.failed?)
|
240
257
|
|
241
258
|
|
242
259
|
end
|
243
260
|
|
244
261
|
module_function
|
262
|
+
|
245
263
|
def at_exit_impl
|
246
264
|
::BrowserStackCucumber::Config.close_browser_force
|
247
265
|
#do global shutdown (i.e. tunnel)
|
@@ -1,6 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'cucumber/formatter/junit'
|
2
2
|
|
3
3
|
module BrowserStackCucumber
|
4
|
+
#noinspection RubyUnusedLocalVariable,RubyUnusedLocalVariable
|
4
5
|
class JenkinsFormatter < Cucumber::Formatter::Junit
|
5
6
|
def initialize(step_mother, io, options)
|
6
7
|
super
|
@@ -20,7 +21,7 @@ module BrowserStackCucumber
|
|
20
21
|
|
21
22
|
def basename(feature_file)
|
22
23
|
filename = super
|
23
|
-
"#{filename}_#{Time.now.strftime(
|
24
|
+
"#{filename}_#{Time.now.strftime('%Y-%m-%d-%H%M%S')}_#{Random.rand(9999).to_s}"
|
24
25
|
end
|
25
26
|
|
26
27
|
|
data/lib/browserstack/version.rb
CHANGED