Ruby:测试没有运行

时间:2014-11-24 07:26:48

标签: ruby unit-testing

我正在尝试运行以下测试:

require 'minitest/spec'
require 'minitest/autorun'

def test_true_is_true
  assert "3".is_a_number?
end

当我运行此文件时,我收到以下输出:

Finished in 0.001183s, 0.0000 runs/s, 0.0000 assertions/s.

0 runs, 0 assertions, 0 failures, 0 errors, 0 skips

为什么我的测试都没有运行?

1 个答案:

答案 0 :(得分:3)

您需要使用继承自MiniTest::Test的类:

require "minitest/autorun"

class TestMe < Minitest::Test
  def test_true_is_true
    assert "3".is_a_number?
  end
end