Calabash - 不要在启动时重新安装应用程序

Calabash - do not reinstall app on startup

我的应用程序在第一个 运行 用户必须进行身份验证。

我有一个具有不同标记场景的功能。现在我需要 运行 几个场景,但每次我 运行 以下命令

calabash-android run /path/to/apk features/my.feature --tags @Alert

我的应用程序已重新安装,导致我的@Alert 场景测试失败。我怎样才能告诉葫芦不要重新安装应用程序?

通过谷歌搜索,我发现 this 上面写着:

Go to app_installation_hooks.rb file under support folder and comment out following 3 lines:

uninstall_apps
install_app(......)
install_app(......)

但我正在寻找一个命令或更优雅的方式来做我想做的事。

我认为您需要更新 app_installation_hooks 并添加标记的 Before 挂钩。

Calabash iOS 烟雾测试 01_launch.rb(是的,这是一个 iOS 示例,但原理相同)有我的意思的示例。

Before('@reset_app_btw_scenarios') do
  if xamarin_test_cloud?
    ENV['RESET_BETWEEN_SCENARIOS'] = '1'
  elsif LaunchControl.target_is_simulator?
    target = LaunchControl.target
    simulator = RunLoop::Device.device_with_identifier(target)
    app = RunLoop::App.new(ENV['APP'])
    core_sim = RunLoop::CoreSimulator.new(simulator, app)
    core_sim.reset_app_sandbox
  else
    LaunchControl.install_on_physical_device
  end
end

Cucumber 提供了许多 hooks 允许我们在 Cucumber 测试周期的不同点 运行 块。

我想你需要的是 Tagged hooks

有时您可能只希望在某些情况下使用特定的挂钩 运行。这可以通过将 Before、After、Around 或 AfterStep 挂钩与一个或多个标签相关联来实现。