首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用rspec实现calabash-ios的问题

用rspec实现calabash-ios的问题
EN

Stack Overflow用户
提问于 2013-07-23 21:11:04
回答 1查看 1K关注 0票数 2

我试图使用rspec (而不是黄瓜)设置Calabash的集成,方法是遵循http://devblog.snap-interactive.com/post/45933948225/mobile-automation-of-ios-native-apps-with-calabash-ios#.Ue6PORz5BhF中提到的步骤,但无法继续。我已经详细列出了我遵循的步骤和调试错误。请与大家分享一下出了什么问题。我对红宝石和葫芦也很陌生。

步骤:I创建了XCodeproject并按照https://github.com/calabash/calabash-ios中提到的步骤配置了项目,在项目目录的终端cd中并安装了rspec gem,rspec -init用于创建spec_helper

我在用鲁比明。

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

TestProject

  • calabash.framework
  • 特性
    • step_definitions

    • 支持

      • 01_launch.rb -I将该文件移到lib目录下,并将其重命名为launch.rb,我在spec_helper.rb中引用了该文件。

      • ..other文件

    • launch.rb

    • MySpec.rb

  • 等级库
    • MySpec_spec.rb

    • spec_helper.rb

  • 其他项目文件夹…。。

在使用rspec时是否应该遵循我在这里缺少的特定格式?(就像我们对于黄瓜特性文件夹、step_definitions等)

我正在张贴我的文件内容:

launch.rb

代码语言:javascript
复制
########################################
#                                      #
#       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

>这样添加APP_BUNDLE_PATH是正确的吗?

如果我有应用程序的源代码,还是只有当我有”时,我才需要在这里添加APP_BUNDLE_PATH?

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

代码语言:javascript
复制
/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

spec_helper.rb

代码语言:javascript
复制
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‘rspec“行上写着”没有这样的文件要加载“,为什么?我确实在项目目录中安装了rspec。

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

代码语言:javascript
复制
/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

请指导一下哪里出了问题。

MySpec_spec.rb

代码语言:javascript
复制
require ‘spec_helper’
.
.
.
.

在终端中执行"rspec规范“的的结果如下:

“for main:Object ( /Users/qateam/Desktop/library_project/TestProject/spec/launch.rb:17:in ) 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”之前的/Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in require' from /Users/qateam/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:inrequire‘for<top (required)>': undefined method/User/qateam/Desktop/library_project/TestProject/spec/PlayWithShopwise_spec.rb:1:in <top (required)>' from /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-加载“从/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 block in load_spec_files' from /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:ineach”2.14.4/lib/rspec/core/ from . in :896:inload_spec_files' from /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运行‘fromrun' from /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 run' from /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:inblock in autorun’

感谢关于这个的任何输入..

如果您有任何calabash的工作示例或任何文档/教程,请共享.

谢谢,

EN

回答 1

Stack Overflow用户

发布于 2015-05-01 13:34:00

我意识到这是一个古老的帖子,但我们一直在使用rspec作为单元和集成测试卡拉巴斯iOS和运行循环宝石。使用rspec作为测试运行是100%的可能,但是您需要自己配置运行程序。我最好的建议是使用before(:all)块来启动这个应用程序。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17821157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档