Class: Maze::Hooks::AppiumHooks

Inherits:
InternalHooks show all
Defined in:
lib/maze/hooks/appium_hooks.rb

Overview

Hooks for Appium mode use

Instance Method Summary collapse

Instance Method Details

#after(scenario) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/maze/hooks/appium_hooks.rb', line 17

def after(scenario)

  if Maze.config.os == 'macos'
    # Close the app - without the sleep, launching the app for the next scenario intermittently fails
    system("killall -KILL #{Maze.config.app} && sleep 1")
  elsif [:bb, :bs, :local].include? Maze.config.farm
    write_device_logs(scenario) if scenario.failed?

    # appium_lib 12 says that reset is deprecated and activate_app/terminate_app should be used
    # instead.  However, they do not clear out app data, which we need between scenarios.
    # install_app/remove_app might also be an option to consider.
    Maze.driver.reset
  end
end

#after_allObject



32
33
34
35
36
37
38
39
# File 'lib/maze/hooks/appium_hooks.rb', line 32

def after_all
  @client&.log_run_outro
  if $success
    Maze::Plugins::DatadogMetricsPlugin.send_increment('appium.test_succeeded')
  else
    Maze::Plugins::DatadogMetricsPlugin.send_increment('appium.test_failed')
  end
end

#at_exitObject



41
42
43
# File 'lib/maze/hooks/appium_hooks.rb', line 41

def at_exit
  @client&.stop_session
end

#before(scenario) ⇒ Object



13
14
15
# File 'lib/maze/hooks/appium_hooks.rb', line 13

def before(scenario)
  @client.start_scenario
end

#before_allObject



8
9
10
11
# File 'lib/maze/hooks/appium_hooks.rb', line 8

def before_all
  Maze::Plugins::DatadogMetricsPlugin.send_increment('appium.test_started')
  @client = Maze::Client::Appium.start
end