用Shoulda进行单元测试

时间:2010-08-30 16:00:23

标签: ruby unit-testing shoulda

编辑:此问题有时只会发生

这种情况似乎只发生在我从TextMate中运行测试时(即使我指定了ruby来手动使用shebang运行它)。如果我从终端运行它,那么一切都很好......


以下是一些代码:

require 'test/unit'
require 'shoulda'

class TestingTest < Test::Unit::TestCase
  context "My thing" do  
    should "always have this test fail, and give me this message" do
      assert false
    end
  end
end

我希望它告诉我类似的事情:

1) Failure:
test: My thing should always have this test fail, and give me this message (TestingTest)
# etc
An assert message, if one was given

但我得到了:

1) Failure:
test:8
Failed assertion, no message given.

那我错过了什么?上面的示例代码就像我想的那样简单,我无法看到问题!

1 个答案:

答案 0 :(得分:0)

尝试继承ActiveSupport::TestCase而不是Test :: Unit :: TestCase