运行功能时出现黄瓜安卓错误

时间:2014-07-29 11:20:08

标签: android cucumber automated-tests calabash

我正在尝试用黄瓜测试来测试android程序。

我有这样的错误:

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

我的功能很简单:

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

我想在不重新安装应用程序的情况下启动功能,因为我想保存数据。

P.S。我可以毫无错误地运行calabash控制台。

1 个答案:

答案 0 :(得分:0)

我更改了app_installation_hooks.rb:

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

现在我运行app:

calabash-android run <apk>