【问题标题】:How to activate test-unit for RubyMine when developing a library (gem)?开发库(gem)时如何激活 RubyMine 的测试单元?
【发布时间】:2012-01-17 11:36:34
【问题描述】:

我正在使用 Ruby 1.9.2 开发一个库(一个 gem)。我的 Gemspec 看起来像普通的宝石:

source "http://rubygems.org"

# Specify your gem's dependencies in table_builder.gemspec
gemspec

在我的 gemspec 中,我有这一行:

s.add_development_dependency "test-unit"

我可以看到它正在安装并且我的 Gemfile.lock 包含它:

PATH
  remote: .
  specs:
    foobar (0.0.1)

GEM
  remote: http://rubygems.org/
  specs:
    test-unit (2.4.5)

PLATFORMS
  ruby

DEPENDENCIES
  foobar!
  test-unit

在我的 Rakefile 中,我加载它:

require "rubygems"
require "test/unit"

以及在我的 test_helper.rb 中:

require "rubygems"
require "test/unit"

在命令行中测试运行并通过,但在 RubyMine 中,无论我运行测试还是测试 rake 任务,我都会收到以下消息:

检测到 MiniTest 框架。这是原版的限定版 测试::单元框架。 RubyMine/IDEA Ruby 插件测试运行器需要 框架的全功能版本,否则默认控制台 将使用测试报告器。请安装“测试单元”gem 并在运行时激活它。

我使用的是 RVM,所以我检查了 SDK 是我在命令行上使用的那个,并且 test-unit 列在已安装的 gem 列表中。

那么,我如何以 RubyMine 喜欢的方式激活测试单元?

【问题讨论】:

    标签: ruby gem rubymine testunit


    【解决方案1】:

    refer to help。您需要 Gemfile 以及其中列出的使用过的 gem,以便 RubyMine 识别依赖关系。

    【讨论】:

    • 这将违反 gems 的常见做法,即在 gemspec 中列出依赖项,而在 Gemfile 中只指向 gemspec。你确定 RubyMine 不明白吗?
    • 确保在运行/调试配置的 Bundler 选项卡中启用了“在包的上下文中运行此脚本”选项。
    【解决方案2】:

    RubyMine 4.0(在撰写本文时为 RC2)支持 minitest 并设法开箱即用地运行测试。加油 JetBrains!

    【讨论】:

      猜你喜欢
      • 2021-04-05
      • 2022-07-09
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      • 2014-08-25
      • 1970-01-01
      • 1970-01-01
      • 2011-06-01
      相关资源
      最近更新 更多