1

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

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

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

我已阅读有关 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

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

4

1 回答 1

0

为了解决它,我首先按以下方式重组了我的项目

/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并将测试文件夹标记为Test(这应该会改变文件夹图标的颜色)。

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

于 2015-11-17T10:11:02.820 回答