用rspec实现葫芦ios的问题

用rspec实现葫芦ios的问题,ios,rspec,calabash,Ios,Rspec,Calabash,我正试图按照中提到的步骤,使用rspec(而不是cucumber)设置葫芦iOS的集成 但无法继续。我已经详细列出了我遵循的步骤以及调试错误。请告诉我出了什么问题。。我对ruby和葫芦都是新手 步骤: 我创建了XCodeproject,并按照中提到的步骤将项目配置到项目目录的终端cd中,并安装了rspecgem,执行rspec–init以创建spec_助手 我用的是红霉素 以以下形式存在的树结构: 测试项目 葫芦框架 特征 步骤u定义 支持 01_launch.rb–我将此文件移动

我正试图按照中提到的步骤,使用rspec(而不是cucumber)设置葫芦iOS的集成 但无法继续。我已经详细列出了我遵循的步骤以及调试错误。请告诉我出了什么问题。。我对ruby和葫芦都是新手

步骤: 我创建了XCodeproject,并按照中提到的步骤将项目配置到项目目录的终端cd中,并安装了rspecgem,执行rspec–init以创建spec_助手

我用的是红霉素

以以下形式存在的树结构:

测试项目

  • 葫芦框架
  • 特征
    • 步骤u定义
    • 支持
      • 01_launch.rb–我将此文件移动到lib目录下,并重命名为launch.rb,我在spec_helper.rb中引用了它
      • …其他文件
  • 解放党
    • launch.rb
    • MySpec.rb
  • 规格
    • MySpec_spec.rb
    • spec_helper.rb
  • 其他项目文件夹
在使用rspec时,是否有我在这里遗漏的特定格式需要遵循?(如cucumber features文件夹、step_定义等)

我正在发布我的文件内容:

launch.rb

########################################
#                                      #
#       Important Note                 #
#                                      #
#   When running calabash-ios tests at #
#   www.xamarin.com/test-cloud         #
#   this file will be overwritten by   #
#   a file which automates             #
#   app launch on devices.             #
#                                      #
#   Don't rely on this file being      #
#   present when running at            #
#   Xamarin Test Cloud                 #
#                                      #
########################################

require 'calabash-cucumber/launcher'

APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/MyApp-dftlalczpovmeddcybgllunvwpoe/Build/Products/Release-iphonesimulator/MyApp.app" 


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

After do |scenario|
  unless @calabash_launcher.calabash_no_stop?
    calabash_exit
    @calabash_launcher.stop
  end
end

at_exit do
  launcher = Calabash::Cucumber::Launcher.new
  if launcher.simulator_target?
    Calabash::Cucumber::SimulatorHelper.stop unless launcher.calabash_no_stop?
  end
end
require_relative '../lib/launch'
require ‘rspec’

require ‘rubygems’
require 'calabash-cucumber/core'
require 'calabash-cucumber/tests_helpers'
require 'calabash-cucumber/keyboard_helpers'
require 'calabash-cucumber/wait_helpers'
require 'calabash-cucumber/operations'
require 'calabash-cucumber/version'
require 'calabash-cucumber/location'
require 'calabash-cucumber/ibase'
include Calabash::Cucumber::Core
include Calabash::Cucumber::WaitHelpers
include Calabash::Cucumber::TestsHelpers
include Calabash::Cucumber::Operations

# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
  config.treat_symbols_as_metadata_keys_with_true_values = true
  config.run_all_when_everything_filtered = true
  config.filter_run :focus

  # Run specs in random order to surface order dependencies. If you find an
  # order dependency and want to debug it, you can fix the order by providing
  # the seed, which is printed after each run.
  #     --seed 1234
  config.order = 'random'
end
require ‘spec_helper’
.
.
.
.
>这样添加应用程序包路径正确吗?

>如果我有应用程序的源代码,还是只有当我有.APP“

在调试launch.rb时,我遇到以下错误,请有人帮助解决此问题:

/Users/qateam/.rbenv/versions/2.0.0-p247/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/qateam/Desktop/library_project/TestProject/lib/launch.rb
/Users/qateam/Desktop/library_project/TestProject/lib/launch.rb:30:in `<top (required)>': undefined method `Before' for main:Object (NoMethodError)
    from -e:1:in `load'
    from -e:1:in `<main>'

Process finished with exit code 1
请注意:

行“require'rspec'”表示“没有要加载的文件”,为什么?我确实在项目目录中安装了rspec gem

在调试spec_helper.rb时,我遇到以下错误:

/Users/qateam/.rbenv/versions/2.0.0-p247/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/qateam/Desktop/library_project/TestProject/spec/spec_helper.rb
/Users/qateam/Desktop/library_project/TestProject/lib/launch.rb:30:in `<top (required)>': undefined method `Before' for main:Object (NoMethodError)
    from /Users/qateam/Desktop/library_project/TestProject/spec/spec_helper.rb:1:in `require_relative'
    from /Users/qateam/Desktop/library_project/TestProject/spec/spec_helper.rb:1:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

Process finished with exit code 1

在终端中执行“rspec规范”会导致以下结果:

/Users/qateam/Desktop/library_project/TestProject/spec/launch.rb:17:in
':未定义的方法
来自/Users/qateam/Desktop/library\u project/TestProject/spec/spec\u helper.rb:1:in
require\u relative'
from/Users/qateam/Desktop/library_project/TestProject/spec/spec_helper.rb:1:in
' 来自/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/site\u ruby/2.0.0/rubygems/core\u ext/kernel\u require.rb:51:in
require'
来自/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/site\u ruby/2.0.0/rubygems/core\u ext/kernel\u require.rb:51:in
require' from/Users/qateam/Desktop/library\u project/TestProject/spec/PlayWithShopwise\u spec.rb:1:in
'
来自/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.4/lib/rspec/core/configuration.rb:896:in
load' 来自/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.4/lib/rspec/core/configuration.rb:896:in
加载规范文件中的块
来自/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.4/lib/rspec/core/configuration.rb:896:in
来自/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.4/lib/rspec/core/configuration.rb:896:in
加载规范文件
来自/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:22:in
run' 来自/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.4/lib/rspec/core/runner.rb:80:in
run'
来自/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.4/lib/rspec/core/runner.rb:17:in
自动运行中的块

感谢您对此的任何意见。

如果您有葫芦rspec的任何工作示例或任何文档/教程,请与他人分享。


谢谢,

我意识到这是一篇古老的文章,但我们一直在使用rspec对葫芦iOS和run loop gems进行单元和集成测试。使用rspec作为测试运行是100%可能的,但您需要自己配置运行程序。我的最佳建议是在(:all)之前使用
block启动应用程序。

您好,您可以尝试此更改。请将您的step文件重新命名为前缀\u steps.rb,然后重试。“文件名..\u steps.rb”您好,谢谢您的回复。我没有使用Cucumber(因此,我的项目中没有step\u definitions文件夹,因此也没有\u steps.rb文件)。我正在尝试rspec。不确定我为什么会收到“文件名”launch.rb:30:in
':在“for main:Object(NoMethodError)”之前未定义方法调试时出现此错误。。