Skip to content

Commit

Permalink
Merge pull request #1247 from bugsnag/tms/get-platform
Browse files Browse the repository at this point in the history
Use Maze Runner helper routine
  • Loading branch information
twometresteve authored Dec 7, 2021
2 parents 185098b + cf2200d commit 4b1e72c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ gem 'xcpretty'

# A reference to Maze Runner is only needed for running tests locally and if committed it must be
# portable for CI, e.g. a specific release. However, leaving it commented out would mean quicker CI.
gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', tag: 'v6.5.0'
gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', tag: 'v6.6.2'

# Use a development branch
#gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', branch: 'tms/update-cucumber'
# Use a specific branch
#gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', branch: 'master'

# Locally, you can run against Maze Runner branches and uncommitted changes:
#gem 'bugsnag-maze-runner', path: '../maze-runner'
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
GIT
remote: https://github.com/bugsnag/maze-runner
revision: fd33f19db2d0b03be857fecb55f1aa4d4033de6c
tag: v6.5.0
revision: 9efc4f0c876f050d34e0bef54be2599598076818
tag: v6.6.2
specs:
bugsnag-maze-runner (6.5.0)
bugsnag-maze-runner (6.6.2)
appium_lib (~> 11.2.0)
bugsnag (~> 6.24)
cucumber (~> 7.1)
Expand Down Expand Up @@ -41,7 +41,7 @@ GEM
faye-websocket (~> 0.11.0)
selenium-webdriver (~> 3.14, >= 3.14.1)
atomos (0.1.3)
bugsnag (6.24.0)
bugsnag (6.24.1)
concurrent-ruby (~> 1.0)
builder (3.2.4)
childprocess (3.0.0)
Expand Down
14 changes: 7 additions & 7 deletions features/steps/app_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
end

When('I relaunch the app') do
case Maze.driver.capabilities['platformName']
when 'Mac'
case Maze::Helper.get_current_platform
when 'macos'
app = Maze.driver.capabilities['app']
system("killall #{app} > /dev/null && sleep 1")
Maze.driver.get(app)
Expand All @@ -17,8 +17,8 @@
# This step should only be used when the app has crashed, but the notifier needs a little
# time to write the crash report before being forced to reopen. From trials, 2s was not enough.
sleep(5)
case Maze.driver.capabilities['platformName']
when 'Mac'
case Maze::Helper.get_current_platform
when 'macos'
Maze.driver.get(Maze.driver.capabilities['app'])
else
Maze.driver.launch_app
Expand Down Expand Up @@ -48,10 +48,10 @@

Then('the app is not running') do
wait_for_true do
case Maze.driver.capabilities['platformName']
when 'iOS'
case Maze::Helper.get_current_platform
when 'ios'
Maze.driver.app_state('com.bugsnag.iOSTestApp') == :not_running
when 'Mac'
when 'macos'
`lsappinfo info -only pid -app com.bugsnag.macOSTestApp`.empty?
else
raise "Don't know how to query app state on this platform"
Expand Down
33 changes: 18 additions & 15 deletions features/steps/cocoa_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
step("I run \"#{event_type}\"")
rescue StandardError
# Ignore on macOS - AppiumForMac raises an error when clicking a button causes the app to crash
raise unless Maze.driver.capabilities['platformName'].eql?('Mac')
raise unless Maze::Helper.get_current_platform.eql?('macos')

$logger.warn 'Ignoring error - this is normal for AppiumForMac if a button click causes the app to crash.'
end
Expand All @@ -25,7 +25,7 @@
Given I click the element "run_scenario"
)
rescue StandardError
raise unless Maze.driver.capabilities['platformName'].eql?('Mac')
raise unless Maze::Helper.get_current_platform.eql?('macos')
$logger.info 'Ignored error raised by AppiumForMac when clicking run_scenario'
end
steps %(
Expand All @@ -52,7 +52,7 @@ def click_if_present(element)
end

When('I close the keyboard') do
unless Maze.driver.capabilities['platformName'].eql?('Mac')
unless Maze::Helper.get_current_platform.eql?('macos')
click_if_present 'close_keyboard'
end
end
Expand Down Expand Up @@ -193,49 +193,52 @@ def check_device_model(field, list)
end

Then('the error is valid for the error reporting API') do
case Maze.driver.capabilities['platformName']
when 'iOS'
platform = Maze::Helper.get_current_platform
case platform
when 'ios'
steps %(
Then the error is valid for the error reporting API version "4.0" for the "iOS Bugsnag Notifier" notifier
Then the breadcrumb timestamps are valid for the event
)
when 'Mac'
when 'macos'
steps %(
Then the error is valid for the error reporting API version "4.0" for the "OSX Bugsnag Notifier" notifier
Then the breadcrumb timestamps are valid for the event
)
else
raise 'Unknown platformName'
raise "Unknown platform: #{platform}"
end
end

Then('the error is valid for the error reporting API ignoring breadcrumb timestamps') do
case Maze.driver.capabilities['platformName']
when 'iOS'
platform = Maze::Helper.get_current_platform
case platform
when 'ios'
steps %(
Then the error is valid for the error reporting API version "4.0" for the "iOS Bugsnag Notifier" notifier
)
when 'Mac'
when 'macos'
steps %(
Then the error is valid for the error reporting API version "4.0" for the "OSX Bugsnag Notifier" notifier
)
else
raise 'Unknown platformName'
raise "Unknown platform: #{platform}"
end
end

Then('the session is valid for the session reporting API') do
case Maze.driver.capabilities['platformName']
when 'iOS'
platform = Maze::Helper.get_current_platform
case platform
when 'ios'
steps %(
Then the session is valid for the session reporting API version "1.0" for the "iOS Bugsnag Notifier" notifier
)
when 'Mac'
when 'macos'
steps %(
Then the session is valid for the session reporting API version "1.0" for the "OSX Bugsnag Notifier" notifier
)
else
raise 'Unknown platformName'
raise "Unknown platform: #{platform}"
end
end

Expand Down
8 changes: 4 additions & 4 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@
end

def skip_below(os, version)
skip_this_scenario("Skipping scenario") if Maze.driver.capabilities['platformName'] == os and Maze.config.os_version < version
skip_this_scenario("Skipping scenario") if Maze::Helper.get_current_platform == os and Maze.config.os_version < version
end

Before('@skip_below_ios_11') do |scenario|
skip_below('iOS', 11)
skip_below('ios', 11)
end

Before('@skip_below_ios_13') do |scenario|
skip_below('iOS', 13)
skip_below('ios', 13)
end

Before('@skip_macos') do |scenario|
skip_this_scenario("Skipping scenario") if Maze.driver.capabilities['platformName'] == 'Mac'
skip_this_scenario("Skipping scenario") if Maze::Helper.get_current_platform == 'macos'
end

# Skip stress tests unless STRESS_TEST env var is set
Expand Down

0 comments on commit 4b1e72c

Please sign in to comment.