简体   繁体   English

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

[英]RubyMine Unit tests - Test Framework quit unexpectedly

When I try to run the tests from within RubyMine I have an issue. 当我尝试从RubyMine中运行测试时,我遇到了问题。 But what is strange is that it work fine when I run the tests from the command line. 但奇怪的是,当我从命令行运行测试时,它工作正常。

"Test framework quit unexpectedly" “测试框架意外退出”

在此输入图像描述

/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

Maybe the problem come from that line ? 也许问题来自那条线?

/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 ? /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:警告:嵌套重复运算符+和? was replaced with '*' ... 被'*'取代......

Mode: Test script Use pre-load server: none Ruby arguments: -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -Itest Ruby SDK: project 模式:测试脚本使用预加载服务器:Ruby参数: -e $ stdout.sync = true; $ stderr.sync = true; load($ 0 = ARGV.shift)-Itest Ruby SDK: project

But I would love to have something like this: 但是我希望有这样的东西:

在此输入图像描述

Thank you 谢谢

There is a nice tutorial for setting up RubyMine tests in their online help, which helped me resolve the same problem as you describe (for Test::Unit -style tests). 有一个很好的教程可以在他们的在线帮助中设置RubyMine测试,这有助于我解决你描述的相同问题(对于Test::Unit style测试)。 Basically you need to include the minitest and minitest-reporters gems into your project and add a call to use the new format of tests reporting: 基本上,您需要将minitestminitest-reporters gems包含到您的项目中,并添加一个调用以使用新的测试报告格式:

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

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

Take a look at the tutorial for more options. 查看教程以获取更多选项。

I had the same problem, and it was caused by not installing (globally?) the ruby gems of the testing library. 我遇到了同样的问题,这是因为没有安装(全局?)测试库的ruby gems。 For instance, for the minitest testing framework (you didn't specify which one you use), just run from command line: 例如,对于minitest测试框架(您没有指定使用哪一个),只需从命令行运行:

gem install minitest
gem install minitest-reporters

This solved the problem to me. 这解决了我的问题。

I had the same problem when running from RubyMine (but not from command line). 从RubyMine运行时我遇到了同样的问题(但不是从命令行运行)。 It was fixed by restarting spring: 它通过重新启动弹簧来修复:

bin/spring stop
bin/spring status

You can fix it specifying the PATH for RSpec. 您可以修复它,指定RSpec的PATH。 To find the right path in Ubuntu, I used the command 为了在Ubuntu中找到正确的路径,我使用了该命令

whereis rpsec 哪里是rpsec

In RubyMine, go to menu "Run" > "Edit Configurations", mark "Use custom RSpec runner script", and set the path found previously. 在RubyMine中,转到菜单“运行”>“编辑配置”,选中“使用自定义RSpec转轮脚本”,然后设置之前找到的路径。

我有同样的问题,我通过从Gemfile中删除'guard-minitest'来解决这个问题

You should be sure that your test suite is running with RAILS_ENV=test 您应该确保您的测试套件使用RAILS_ENV=test运行

For RubyMine you can set this up in Run > Edit Configurations.. > Choose test suite you want to run (ie spec: project_name) > Environment variables and there add variable mentioned above. 对于RubyMine,您可以在Run > Edit Configurations.. > Choose test suite you want to run (ie spec: project_name) > Environment variables然后添加上面提到的变量。

You can get this error when some of the gems are not checked out, so you will need to run bundle install . 如果未检出某些gem,您可能会收到此错误,因此您需要运行bundle install Run your test from terminal and you will get an error if that is your case 从终端运行测试,如果是这种情况,您将收到错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM