From 149f0441557affdaa73393428d5b8a8e73fb73d3 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Sat, 22 Nov 2014 15:42:18 +1100 Subject: [PATCH] Add Testmunk files --- android/test/features/load-app.feature | 5 +++ .../step_definitions/calabash_steps.rb | 1 + .../features/step_definitions/my_steps.rb | 6 ++++ .../support/app_installation_hooks.rb | 36 +++++++++++++++++++ .../features/support/app_life_cycle_hooks.rb | 13 +++++++ android/test/features/support/env.rb | 1 + android/test/features/support/hooks.rb | 0 7 files changed, 62 insertions(+) create mode 100644 android/test/features/load-app.feature create mode 100755 android/test/features/step_definitions/calabash_steps.rb create mode 100644 android/test/features/step_definitions/my_steps.rb create mode 100755 android/test/features/support/app_installation_hooks.rb create mode 100755 android/test/features/support/app_life_cycle_hooks.rb create mode 100755 android/test/features/support/env.rb create mode 100755 android/test/features/support/hooks.rb diff --git a/android/test/features/load-app.feature b/android/test/features/load-app.feature new file mode 100644 index 000000000..e6bd1158a --- /dev/null +++ b/android/test/features/load-app.feature @@ -0,0 +1,5 @@ +Feature: Testapp V.1.2 + +Scenario: 1) Start app and load map + Given I await for 5 seconds + diff --git a/android/test/features/step_definitions/calabash_steps.rb b/android/test/features/step_definitions/calabash_steps.rb new file mode 100755 index 000000000..6d80ff0c9 --- /dev/null +++ b/android/test/features/step_definitions/calabash_steps.rb @@ -0,0 +1 @@ +require 'calabash-android/calabash_steps' diff --git a/android/test/features/step_definitions/my_steps.rb b/android/test/features/step_definitions/my_steps.rb new file mode 100644 index 000000000..3239322dd --- /dev/null +++ b/android/test/features/step_definitions/my_steps.rb @@ -0,0 +1,6 @@ + +Then /^I await for ([\d\.]+) second(?:s)?$/ do |num_seconds| +num_seconds = num_seconds.to_f +sleep num_seconds + +end diff --git a/android/test/features/support/app_installation_hooks.rb b/android/test/features/support/app_installation_hooks.rb new file mode 100755 index 000000000..2e0a203bc --- /dev/null +++ b/android/test/features/support/app_installation_hooks.rb @@ -0,0 +1,36 @@ +require 'calabash-android/management/app_installation' + +AfterConfiguration do |config| + FeatureNameMemory.feature_name = nil +end + +Before do |scenario| + @scenario_is_outline = (scenario.class == Cucumber::Ast::OutlineTable::ExampleRow) + if @scenario_is_outline + scenario = scenario.scenario_outline + end + + feature_name = scenario.feature.title + if FeatureNameMemory.feature_name != feature_name \ + or ENV["RESET_BETWEEN_SCENARIOS"] == "1" + if ENV["RESET_BETWEEN_SCENARIOS"] == "1" + log "New scenario - reinstalling apps" + else + log "First scenario in feature - reinstalling apps" + end + + uninstall_apps + install_app(ENV["TEST_APP_PATH"]) + install_app(ENV["APP_PATH"]) + FeatureNameMemory.feature_name = feature_name + FeatureNameMemory.invocation = 1 + else + FeatureNameMemory.invocation += 1 + end +end + +FeatureNameMemory = Class.new +class << FeatureNameMemory + @feature_name = nil + attr_accessor :feature_name, :invocation +end diff --git a/android/test/features/support/app_life_cycle_hooks.rb b/android/test/features/support/app_life_cycle_hooks.rb new file mode 100755 index 000000000..63d4678d9 --- /dev/null +++ b/android/test/features/support/app_life_cycle_hooks.rb @@ -0,0 +1,13 @@ +require 'calabash-android/management/adb' +require 'calabash-android/operations' + +Before do |scenario| + start_test_server_in_background +end + +After do |scenario| + if scenario.failed? + screenshot_embed + end + shutdown_test_server +end diff --git a/android/test/features/support/env.rb b/android/test/features/support/env.rb new file mode 100755 index 000000000..bb2505d45 --- /dev/null +++ b/android/test/features/support/env.rb @@ -0,0 +1 @@ +require 'calabash-android/cucumber' diff --git a/android/test/features/support/hooks.rb b/android/test/features/support/hooks.rb new file mode 100755 index 000000000..e69de29bb