【问题标题】:Cucumber android error while running feature运行功能时黄瓜android错误
【发布时间】:2014-07-29 11:20:08
【问题描述】:

我正在尝试用黄瓜测试来测试 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

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

附:我可以正常运行葫芦控制台。

【问题讨论】:

    标签: android cucumber automated-tests calabash


    【解决方案1】:

    我将 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
    

    现在我运行应用程序:

    calabash-android run <apk>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-04
      • 1970-01-01
      • 2019-01-29
      • 2011-11-23
      • 1970-01-01
      • 2017-12-13
      • 1970-01-01
      相关资源
      最近更新 更多