【问题标题】:rubyMine 'Unable to attach test reporter to test framework'rubyMine '无法将测试报告器附加到测试框架'
【发布时间】:2011-09-24 13:10:16
【问题描述】:

运行所有模型测试时,rubyMine 'MiniTest framework was detected' 错误。

我可以在常规命令行中运行所有模型测试。 例如rake spec:models
当我使用 ruby​​Mine 时:
我可以运行一个模型测试。
但是,当我尝试在模型中运行所有测试时,我得到
MiniTest framework was detected. It is a limited version of original Test::Unit framework. RubyMine/IDEA Ruby plugin test runner requires full-featured version of the framework, otherwise default console tests reporter will be used instead. Please install 'test-unit' gem and activate it on runtime.

我尝试将“测试单元”添加到我的 Gemfile 并重新打包,但现在得到:

`/home/durrantm/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) 
  /home/durrantm/Downloads/RubyMine-3.2.3/rb/testing/runner/tunit_in_folder_runner.rb
Testing started at 9:33 AM ...
Work directory: /home/durrantm/Dropbox_not_syncd/webs/3/rubyists/spec/models}
Loading files.... 
=========================================
0 files were loaded.
=========================================
Searching test suites...
=========================================
0 test suites, 0 tests, 0 assertions, 0 failures, 0 errors
Process finished with exit code 0`

注意:工作目录中的有趣 }。我仍然收到Unable to attach test_reporter to test fraemwork message

版本: Ubuntu 11 RubyMine 3.2

【问题讨论】:

    标签: ruby-on-rails testing model rspec rubymine


    【解决方案1】:

    我终于让它工作了。 主要是通过更改菜单下的内容:
    运行 -> 编辑配置 -> 点击 Rspec -> 创建新配置。

    对于新配置,请确保 specs 文件夹指向应用程序规范模型。

    最后一步(真正让它工作的那一步)是将工作目录(仍在运行/调试配置屏幕上)设置为我的应用程序根目录!

    我还做的另一件事是将gem 'test-unit' 添加到 Gemfile 并捆绑它。然而后来的测试(删除它并解绑)表明它不是必需的,实际上是在使用空套件进行多次测试(可能尝试使用默认 unit::test 以及运行 rspec)。

    【讨论】:

    • 我有一个类似的问题stackoverflow.com/questions/7575057/…,我的工作目录指向应用程序的根目录。请帮忙。谢谢!
    • 这也解决了我的问题:/usr/local/rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45 :in `require': 无法加载这样的文件 -- spec_helper (LoadError)
    【解决方案2】:

    我也有这个问题,但解决方法与其他海报不同。

    在 ruby​​mine 中,我添加了 minitest-reporters gem。然后在我的 minitest_helper.rb 我添加了以下内容:

    require "minitest/reporters"
    MiniTest::Unit.runner = MiniTest::SuiteRunner.new
    MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMineReporter.new
    

    【讨论】:

    • 这也可以,虽然我无法让 RubyMine 自动包含 *_helper.rb 脚本,但必须在规范中要求才能执行。 this one 也是一个有用的指南,请务必使用 Minitest 运行配置并设置运行目录,如上述答案中所述
    • 这对我来说不太适用,因为 MiniTest::SuiteRunner 没有定义。但是,jetbrains.com/ruby/webhelp/minitest.html 说我需要将以下内容用于“0.8.0 及更高版本”并且它有效:require 'minitest/reporters'; MiniTest::Reporters.use!
    【解决方案3】:

    在我的系统上,问题出在“红绿”宝石上。它会根据成功或失败自动为进度标记(点)和 Test::Unit 摘要消息着色。 RubyMine 中一定有一些东西试图解析 Test::Unit 结果(我想是“rake test”的输出),并且它在 ANSI 序列上阻塞。

    我在我的 test/test_helper.rb 中注释掉了“require 'redgreen'”,问题就消失了。不过,我真的很喜欢 redgreen 从 shell 执行“rake 测试”,所以我把它放在 test_helper 中,让它在“rake 测试”和 RubyMine 中都能工作:

    require 'redgreen' if $stdin.tty?

    可能不是红绿导致您的问题,但要怀疑任何可能产生非常规 Test::Unit 输出的东西。

    祝你好运!

    【讨论】:

      【解决方案4】:

      对我来说,我通过确保文件命名正确解决了这个问题。需要以单词 test 开头或以单词 test 结尾。这实际上取决于您在测试配置下的“测试文件名掩码”。对我来说,我的是:*/{_test,test_*}.rb

      例如:test_case_01.rbcase_01_test.rb

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-17
        • 2014-08-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多