RubyMine单元测试 - 测试框架意外退出

时间:2014-07-04 08:50:28

标签: ruby-on-rails unit-testing rvm rubymine jetbrains-ide

当我尝试从RubyMine中运行测试时,我遇到了问题。但奇怪的是,当我从命令行运行测试时,它工作正常。

"测试框架意外退出"

enter image description here

/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -Itest /Users/sabour/Desktop/EIP/project/test/controllers/categories_controller_test.rb
Testing started at 1:39 AM ...
Run options: --seed 14336

# Running tests:

/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228: warning: nested repeat operator + and ? was replaced with '*'
...

Finished tests in 2.554592s, 1.1744 tests/s, 8.6119 assertions/s.

3 tests, 22 assertions, 0 failures, 0 errors, 0 skips

Process finished with exit code 0

也许问题来自那条线?

  

/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:警告:嵌套重复运算符+和?被替换为' *' ...

模式:测试脚本 使用预加载服务器: Ruby参数: -e $ stdout.sync = true; $ stderr.sync = true; load($ 0 = ARGV.shift)-Itest Ruby SDK:项目

但我希望有这样的事情:

enter image description here

谢谢

8 个答案:

答案 0 :(得分:13)

在他们的在线帮助中有一个nice tutorial用于设置RubyMine测试,这有助于我解决您描述的相同问题(对于Test::Unit - 样式测试)。基本上,您需要将minitestminitest-reporters宝石包含到项目中,并添加一个调用以使用新格式的测试报告:

# Gemfile
group :test do
  gem 'minitest'
  gem 'minitest-reporters'
end

# test/test_helper.rb
require 'minitest/reporters'
MiniTest::Reporters.use!

请查看教程以获取更多选项。

答案 1 :(得分:9)

我遇到了同样的问题,这是因为没有安装(全局?)测试库的ruby gems。例如,对于 minitest 测试框架(您没有指定使用哪一个),只需从命令行运行:

gem install minitest
gem install minitest-reporters

这解决了我的问题。

答案 2 :(得分:6)

从RubyMine运行时遇到了同样的问题(但不是从命令行运行)。通过重新启动弹簧来修复它:

bin/spring stop
bin/spring status

答案 3 :(得分:1)

如果您有两个具有相同名称的测试,则也会出现此错误。

答案 4 :(得分:0)

您可以修复它,指定RSpec的PATH。为了在Ubuntu中找到正确的路径,我使用了命令

  

whereis rpsec

在RubyMine中,转到菜单“运行”> “编辑配置”,选中“使用自定义RSpec运行脚本”,并设置之前找到的路径。

答案 5 :(得分:0)

我遇到了同样的问题,我通过删除' guard-minitest'来解决这个问题。来自Gemfile

答案 6 :(得分:0)

您应该确保您的测试套件与RAILS_ENV=test

一起运行

对于RubyMine,您可以在Run > Edit Configurations.. > Choose test suite you want to run (i.e. spec: project_name) > Environment variables中进行设置,并添加上述变量。

答案 7 :(得分:0)

如果没有签出某些宝石,您可能会收到此错误,因此您需要运行bundle install。从终端运行您的测试,如果是您的情况,您将收到错误