【问题标题】:Calabash-android - how to delay the start of the test scenarios to wait for the app to start?Calabash-android - 如何延迟测试场景的启动以等待应用程序启动?
【发布时间】:2016-07-21 20:20:06
【问题描述】:

一旦我按照正确的程序在被测应用上安装葫芦框架,并在使用相关定义步骤编写测试场景后,如果我通过控制台运行:

$ calabash-android console C:\..\app-unaligned.apk
$ start_test_server_in_background

应用程序在我的设备(连接到电脑)上启动没有问题。

当我在命令提示符下运行时:

$ calabash-android run C:\..\app-unaligned.apk

App 大约在 40 秒后启动,显然也是如此,因为在这个时间范围内,前两个测试场景已经离开,无法在 App 中实际启动。当 App 启动时(大约 40 秒后),其余场景(尚未启动)在 App 上正确执行。所以第一个场景失败了,剩下的通过了。

    C:\..\MyApp>calabash-android run C:\..\app-unaligned.apk
    *** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
    Feature: Testing MyApp

    6278 KB/s (585926 bytes in 0.091s)
    6759 KB/s (5721923 bytes in 0.826s)
      Background:                                    # features/my_first.feature:3
      App did not start (RuntimeError)
      ./features/support/app_life_cycle_hooks.rb:5:in `Before'
        Given I wait                                 # calabash-android-0.7.3/lib/calabash-android/steps/progress_steps.rb:5
        Then I press on the tutorial screen          # features/step_definitions/calabash_steps.rb:3
    .
    .
    Scenario: Test One      # features/my_first.feature:14
    .
    .
    Scenario: Test two    # features/my_first.feature:25
    .
    . 
    Scenario: Test three     # features/my_first.feature:60
    .
    .
    Failing Scenarios:
    cucumber features/my_first.feature:14 # Scenario: Test one
    cucumber features/my_first.feature:25 # Scenario: Test two

    3 scenarios (2 failed, 1 passed)
    56 steps (44 skipped, 12 passed)
    1m12.056s

所以我想知道我是否可以将测试场景的启动延迟到移动应用程序真正启动时,以便所有测试场景都有效执行。

【问题讨论】:

    标签: android delay calabash-android


    【解决方案1】:

    使用这个空步骤。

    特点:

    Given App is running
    

    step_definition:

    Given(/^App is running$/) do
    end
    

    这项工作对我来说。

    【讨论】:

    • 谢谢!!但它对我不起作用,前两个场景继续被跳过。
    • 也许尝试在起始页上找到一些元素。并在这一步添加:wait_for_elements_exist("*marked:'element'", :timeout => 100)
    • 在您的 step_definition 中,我添加了:“sleep 40”,因为应用程序在此范围内启动。我相信在运行命令之后,第一个场景是在特定的时间间隔后启动的,如果在这个范围内应用程序没有启动,则会自动跳过该场景,而不需要进入单独的步骤。所以它需要一个命令来延迟开始场景。
    • 睡眠是固定的。 wait_for_elements_exist 超时最大 100 秒。但如果元素存在时间早于 100 秒,则系统进入下一步。
    • 我试过了,还是一样。我认为它需要一个命令来晚启动场景,因为当前两个场景开始时我仍然有:应用程序没有启动(RuntimeError)./features/support/app_life_cycle_hooks.rb:5:in `Before'
    猜你喜欢
    • 2013-10-22
    • 2019-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-02
    • 1970-01-01
    • 2016-07-18
    • 1970-01-01
    相关资源
    最近更新 更多