停止重置模拟器以进行测试

时间:2018-02-06 10:11:20

标签: ruby automated-tests cucumber calabash calabash-ios

我在模拟器上运行Calabash-IOS。如果我在应用程序运行时在终端中键入cucumber,它将关闭整个模拟器,并启动它的新实例,然后运行所有测试。它运行我的所有登录场景和概述,只是为了在用户登录后测试一件事。

有没有办法禁用它,以便测试从我打开视图的位置开始运行?

2 个答案:

答案 0 :(得分:1)

来自Calabash::Cucumber::Launcher文档

  

在控制台中附加到当前启动器

     

如果Calabash已经运行并且您想要附加到当前   启动器,使用console_attach。这在黄瓜情景中很有用   已失败,您想查询应用程序的当前状态。

理论上,这意味着您可以使用console_attach连接到正在运行的calabash实例。

答案 1 :(得分:0)

这是我在support文件夹中的配置:

<强> 01_launch.rb

require 'calabash-cucumber/launcher'

# You can find examples of more complicated launch hooks in these
# two repositories:
#
# https://github.com/calabash/ios-smoke-test-app/blob/master/CalSmokeApp/features/support/01_launch.rb
# https://github.com/calabash/ios-webview-test-app/blob/master/CalWebViewApp/features/support/01_launch.rb

module Calabash::Launcher
  @@launcher = nil

  def self.launcher
    @@launcher ||= Calabash::Cucumber::Launcher.new
  end

  def self.launcher=(launcher)
    @@launcher = launcher
  end
end


$testServerRunning = false


Before do |scenario|
  scenario_tags = scenario.source_tag_names
  if !$testServerRunning || scenario_tags.include?('@restart')
    if $testServerRunning
      shutdown_test_server
    end

    start_test_server_in_background

    $testServerRunning = true
  end
end

After do |scenario|
  Cucumber.wants_to_quit = false
  if scenario.failed?
    screenshot_embed
  end
end

<强> env.rb

require "calabash-cucumber"

# Cucumber -d must pass, but support/env.rb is not eval'd on dry runs.
# We must detect that the user wants to use pre-defined steps.
dir = File.expand_path(File.dirname(__FILE__))
env = File.join(dir, "env.rb")

contents = File.read(env).force_encoding("UTF-8")

contents.split($-0).each do |line|

  # Skip comments.
  next if line.chars[0] == "#"

  if line[/calabash-cucumber\/cucumber/, 0]
    require "calabash-cucumber/calabash_steps"
    break
  end
end