使用 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.
那么我错过了什么?上面的示例代码很简单,我认为我可以做到,但我看不出问题!
edit: this problem only happens sometimes
This only appears to happen when I run the test from within TextMate (even when I specify the ruby to run it from by hand with a shebang). If I run it from the terminal then everything is peachy…
Here's some code:
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
I'm expecting it to tell me something like:
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
But I'm getting:
1) Failure:
test:8
Failed assertion, no message given.
So what am I missing? The example code above is as simple as I think I can make it and I can't see the problem!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试继承
ActiveSupport::TestCase
而不是 Test::Unit::TestCasetry inheriting from
ActiveSupport::TestCase
instead of the Test::Unit::TestCase