Question

I'm trying to test android program with cucumber test.

I have such error:

C:\Users\Artem\calabash_habr>cucumber features/my_first.feature
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
Feature: Pre-orders feature

# Header
Scenario: open Pre-orders   # features\my_first.feature:3
W/asset   ( 2200): Asset path  is neither a directory nor file (type=1).
ERROR: dump failed because assets could not be loaded 'package' not found in aapt output (RuntimeError)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.1/lib/calabash-android/helpers.rb:10:in `package_name'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.1/lib/calabash-android/operations.rb:89:in `uninstall_apps'
C:/Users/Artem/calabash_habr/features/support/app_installation_hooks.rb:22:in `Before'
W/asset   ( 8772): Asset path  is neither a directory nor file (type=1).
ERROR: dump failed because assets could not be loaded 
'package' not found in aapt output (RuntimeError)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.1/lib/calabash-android/helpers.rb:10:in `package_name'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.1/lib/calabash-android/operations.rb:508:in `start_test_server_in_background'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.1/lib/calabash-android/operations.rb:110:in `start_test_server_in_background'
C:/Users/Artem/calabash_habr/features/support/app_life_cycle_hooks.rb:5:in `Before'
When I press the menu key # calabash-android-0.5.1/lib/calabash-android/steps/navigation_steps.rb:5
Could not take screenshot (RuntimeError)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.1/lib/calabash-android/operations.rb:425:in `screenshot'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.1/lib/calabash-android/operations.rb:118:in `screenshot_embed'
C:/Users/Artem/calabash_habr/features/support/app_life_cycle_hooks.rb:10:in `After'
Failing Scenarios:
cucumber features\my_first.feature:3 # Scenario: open Pre-orders

1 scenario (1 failed)
1 step (1 skipped)
0m0.217s

My feature is easy:

Feature: Pre-orders feature
# Header
Scenario: open Pre-orders
# Menu press
When I press the menu key

I want to start feature without reinstalling app, because I want to save data.

P.S. I can run calabash console without error.

Was it helpful?

Solution

I change app_installation_hooks.rb so:

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

After now I run app:

calabash-android run <apk>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top