空测试套件 - 测试单元RubyMine

时间:2015-11-14 13:35:20

标签: ruby unit-testing rubymine testunit rubymine-7

这是我第一次使用RubyMine而我无法让测试框架识别测试。

如果我运行greed.rb文件,它会显示测试结果:

但如果我运行测试,它会显示:

我已阅读question about minitest并试图将其应用于测试单元,但它没有用。

这是我的Gemfile

的内容
gem 'test-unit', '~> 3.0.8'

这是包含测试的ruby类的一部分:

require 'test/unit'

def score(dice)
  # code of the function
end

class Greed < Test::Unit::TestCase
    def test_score_of_an_empty_list_is_zero
      assert_equal 0, score([])
    end
end

我可能遗漏了一些东西,但我还没能找到解决方案。

1 个答案:

答案 0 :(得分:0)

要解决这个问题,我首先按以下方式重新构建项目

Range (2147483647,2147483647)
Range (2147483647,2147483647)
Range (1,7)

然后我将所有测试移动到新文件

/lib
  greed.rb
/tests
  test_greed.rb
Gemfile

最后我转到require './lib/greed.rb' require 'test/unit' class Test_Greed < Test::Unit::TestCase # code for the tests end 并将测试文件夹标记为File/Setting/Project/Project Structure(这应该会更改文件夹图标的颜色)。

现在我可以使用测试框架运行测试了

相关问题