Calabash-cucumber 模拟器不是 运行 与“-cal”方案相同的应用程序版本

Calabash-cucumber simulator not running same version of app as the "-cal" scheme

我从“-cal”方案开始 运行ning 就像 Calabash setup guide 告诉我的那样。然后我运行cucumber换葫芦-iOS。在我的应用程序的不同(可能是缓存版本)中执行测试之前,模拟器似乎停止并重新启动,并且目标设备已从 iPhone 6 更改为 运行 在 [=23] 中执行测试=] 5s.

如何让 cucumber 在已经 运行ning 的“-cal”方案中执行测试?或者(更好)我怎样才能使用“-cal”方案让它重新启动?我可以看到重新启动很有价值的情况。

以下是场景 运行 之前执行的唯一代码。我知道它说 .relaunch 在那里,但如果我把它拿出来,那么第一步测试就会失败。

Before do |scenario|
  @calabash_launcher = Calabash::Cucumber::Launcher.new
  unless @calabash_launcher.calabash_no_launch?
    @calabash_launcher.relaunch
    @calabash_launcher.calabash_notify(self)
  end
end

所以那里的问题很少。

  1. 如何让 cucumber 在已有的 运行“-cal”方案中执行测试? 回答:当您构建校准目标时,您定义要构建的目标,当您执行测试时,您定义要执行的目标。 构建:-sdk iphonesimulator9.0 执行:DEVICE_TARGET='iPhone 6 Plus (9.0)'

  2. 在我的应用程序的不同(可能是缓存版本)中执行测试之前,模拟器似乎停止并重新启动,并且目标设备已从 iPhone 6 更改为 运行 在 iPhone 5 秒内完成测试。 答案:也与问题 1 部分相关(定义目标以控制您测试的设置)。除此之外,该应用程序将在场景之间重新启动,否则每个场景都将取决于之前执行的其他内容。 您可以切换的一件事是应用程序是否应该在场景之间重新安装。如果您有一些仅在第一个 install/launch 上 shows/executes 的功能,这将很有帮助。要添加对重新安装的支持,您可以将类似的内容添加到 "Before do |scenario|"

    中的 launch.rb 文件中

    if scenario_tags.include?('@reinstall') @calabash_launcher.reset_app_sandbox end

The simulator seems to stop and restart before executing the tests

模拟器在每个场景之前退出并重新启动以保持稳定性。如果我们让模拟器保持打开状态,它很快就会变得不稳定。详情见下文。

(possibly cached version) of my app

从 Calabash 0.16.4 要求的 运行-loop 1.5* 开始,这不再是问题。 What version of Calabash are you running? If you are building from the command line and from Xcode, have a look at this project Calabash iOS Smoke Test and specifically this script 将 Xcode 构建的产品暂存到与命令行构建相同的目录。

iPhone 6 to running the tests in an iPhone 5s.

从Xcode7.1开始,默认模拟器是iPhone6。在Xcode7.1之前,默认模拟器已经是iPhone5s。 Lasse 是正确的,使用DEVICE_TARGET 来控制运行 在哪个模拟器上。

How can I make cucumber execute the tests in the already running "-cal" scheme? Or (better yet) how can I make it relaunch using the "-cal" scheme?

您不必在场景之间重新启动。重新启动将重新启动模拟器。如果您不想重新启动,您可以使用自定义葫芦后门在每次测试开始之前将您的应用程序重置为众所周知的状态。我以前一直这样做;它确实加快了测试速度。但是,我放弃了这种方法,因为它很难维护,而且正如我提到的,模拟器变得不稳定。

Or (better yet) how can I make it relaunch using the "-cal" scheme?

这个我其实不太懂。你有设置APP变量吗?另一个应用程序正在启动吗?您 运行 calabash setup 并且您的应用程序是否有 Watch 扩展?如果是这样,您可能 运行 正在解决这个问题:calabash setup adds calabash.framework to Watch extension instead of the app