安装cucumber遇到的几个问题

我的环境是这样的:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14
  - RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x64-mingw32]
  - INSTALLATION DIRECTORY: D:/ruby-2.0.0/lib/ruby/gems/2.0.0
  - RUBY EXECUTABLE: D:/ruby-2.0.0/bin/ruby.exe
  - EXECUTABLE DIRECTORY: D:/ruby-2.0.0/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
*** LOCAL GEMS ***


bigdecimal (1.2.0)
builder (3.2.2)
cucumber (1.3.18)
diff-lcs (1.2.5)
gherkin (2.12.2)
io-console (0.4.2)
json (1.8.1, 1.7.7)
minitest (4.3.2)
multi_json (1.10.1)
multi_test (0.1.1)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rspec (3.1.0)
rspec-core (3.1.7)
rspec-expectations (3.1.2)
rspec-mocks (3.1.3)
rspec-support (3.1.2)
test-unit (2.0.0.0)

问题一:

E:\practice\cucumberdemo>cucumber test.feature
WARNING: cannot load such file -- 2.0/gherkin_lexer_en
Couldn't load 2.0/gherkin_lexer_en
The $LOAD_PATH was:
lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/cucumber-1.3.18/bin/../lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/builder-3.2.2/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/diff-lcs-1.2.5/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/multi_json-1.10.1/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/gherkin-2.12.2/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/multi_test-0.1.1/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/cucumber-1.3.18/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/json-1.8.1/lib
D:/ruby-2.0.0/lib/ruby/site_ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/site_ruby/2.0.0/x64-msvcrt
D:/ruby-2.0.0/lib/ruby/site_ruby
D:/ruby-2.0.0/lib/ruby/vendor_ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/vendor_ruby/2.0.0/x64-msvcrt
D:/ruby-2.0.0/lib/ruby/vendor_ruby
D:/ruby-2.0.0/lib/ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/2.0.0/x64-mingw32. Reverting to Ruby lexer.
WARNING: cannot load such file -- 2.0/gherkin_lexer_en
Couldn't load 2.0/gherkin_lexer_en
The $LOAD_PATH was:
lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/cucumber-1.3.18/bin/../lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/builder-3.2.2/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/diff-lcs-1.2.5/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/multi_json-1.10.1/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/gherkin-2.12.2/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/multi_test-0.1.1/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/cucumber-1.3.18/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/json-1.8.1/lib
D:/ruby-2.0.0/lib/ruby/site_ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/site_ruby/2.0.0/x64-msvcrt
D:/ruby-2.0.0/lib/ruby/site_ruby
D:/ruby-2.0.0/lib/ruby/vendor_ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/vendor_ruby/2.0.0/x64-msvcrt
D:/ruby-2.0.0/lib/ruby/vendor_ruby
D:/ruby-2.0.0/lib/ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/2.0.0/x64-mingw32. Reverting to Ruby lexer.

这种错误,查询了一下google group邮件组的issues,发现是cucumber的一个bug,在Windows 64位系统上会出现,目前消除这种问题的方式是:找到../gems/gherkin-*.*.*/lib/gherkin/c_lexer.rb文件的第七行,修改 prefix = '',避免提示这种错误。


问题二:

按照正常的编写feature文件和step definition,却一直提示步骤未定义。

我之前使用的命令是到当前目录下执行cucumber test.feature,发现不行。改用cucumber cucumberdemo/test.feature -r cucumberdemo 才能执行。这个问题暂时先记着,回来找到原因我再补充。


问题三:

总是提示:cannot load such file -- spec/expectations (LoadError)

这个是因为rspec-expectations在3.0版本以上修改了运行的逻辑,需要在env.rb中把require 'spec/expectations' 修改成 require 'rspec' 才行。



要在CentOS 7上安装Cucumber,您可以按照以下步骤进行操作: 1. 首先,确保您的CentOS 7系统已经安装了Ruby和RubyGems。您可以使用以下命令来检查它们是否已安装: ``` ruby -v gem -v ``` 如果输出显示了对应的版本号,则说明它们已经安装。如果没有安装,请使用以下命令安装Ruby和RubyGems: ``` sudo yum install ruby sudo yum install rubygems ``` 2. 安装Cucumber gem。使用以下命令安装Cucumber: ``` sudo gem install cucumber ``` 3. 等待安装完成后,您可以通过运行以下命令来验证Cucumber是否已成功安装: ``` cucumber --version ``` 如果输出显示了Cucumber的版本号,则说明安装成功。 现在,您已经成功在CentOS 7上安装Cucumber。您可以开始编写和运行Cucumber测试用例了。请参考Cucumber官方文档以了解如何使用Cucumber编写测试用例和运行测试。 <span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span> #### 引用[.reference_title] - *1* *2* *4* [用Ventoy同时引导ubuntu/centos/windows多系统安装](https://blog.csdn.net/moshowgame/article/details/110294922)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [JavaTPoint 工具中文教程【翻译完成】](https://blog.csdn.net/wizardforcel/article/details/122953737)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值