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

Ruby 停止重置模拟器进行测试,ruby,automated-tests,cucumber,calabash,calabash-ios,Ruby,Automated Tests,Cucumber,Calabash,Calabash Ios,我正在模拟器上运行葫芦IOS。如果我在终端中键入cumber,而应用程序已经在运行,它将关闭整个模拟器,并启动它的新实例,然后运行所有测试。它运行我所有的登录场景,并在用户登录后测试一件事 有没有办法禁用此功能,以便测试从我打开视图的位置运行?来自文档 连接到控制台中的当前启动器 如果葫芦已经运行,并且您希望连接到当前 启动器,使用控制台连接。这在出现黄瓜场景时非常有用 已失败,您希望查询应用程序的当前状态 理论上,这意味着您可以使用连接到正在运行的葫芦实例。这是我在support文件夹中的配置

我正在模拟器上运行葫芦IOS。如果我在终端中键入
cumber
,而应用程序已经在运行,它将关闭整个模拟器,并启动它的新实例,然后运行所有测试。它运行我所有的登录场景,并在用户登录后测试一件事

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

来自文档

连接到控制台中的当前启动器

如果葫芦已经运行,并且您希望连接到当前 启动器,使用控制台连接。这在出现黄瓜场景时非常有用 已失败,您希望查询应用程序的当前状态


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

这是我在
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
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
env.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
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

对的当您启动葫芦ios控制台时,它将尝试连接到正在运行的葫芦服务器<代码>控制台_attach不应在测试中使用。我认为这并不能真正回答用户的问题。我认为用户需要使用cucumber标签,在块之前、之后或葫芦后门。是的。这并不能完全回答我的问题。我想从一个特定的视图开始运行我的测试,而不必为了测试一点而通过所有的测试。在这种情况下@jmoody是正确的。您需要在应用程序中设置一个后门,将您导航到正确的ViewController。根据应用程序的复杂性和依赖性,编写这样的路由器可能非常困难。在运行cucumber时,除了重置模拟器之外,没有简单的方法吗?您可以尝试将环境变量
reset\u设置为
“0”
。如果退出应用程序也会导致问题,您可以将
QUIT\u app\u AFTER\u SCENARIO
设置为
“0”