我正在玩Ruby的Test::Unit::TestCase
,尽管我的测试会运行,通过,失败等。我没有看到为每个测试用例输出的点。这是我需要设置的配置,还是我需要指定的冗长级别?Ruby:当我使用Test :: Unit运行测试时,为什么没有点显示?
我运行红宝石2.1.0p0
仅供参考,这里是我的工作的代码。这是从销毁所有的软件截屏,其中的运动是从头开始构建RSpec的(不是整个事情,当然):
测试:
#test_spec.rb
require 'test/unit'
require_relative 'spec'
class TestDescribe < Test::Unit::TestCase
def test_that_it_can_pass
describe 'some thing' do
it 'has some property' do
end
end
end
def test_that_it_can_fail
assert_raise(IndexError) do
describe 'some failing thing' do
it 'fails' do
raise IndexError
end
end
end
end
end
class TestAssertion < Test::Unit::TestCase
def test_that_it_can_pass
2.should == 2
end
def test_that_it_can_fail
assert_raise(AssertionError) do
1.should == 2
end
end
end
,代码:
#spec.rb
def describe(description, &block)
ExampleGroup.new(block).evaluate!
end
class ExampleGroup
def initialize(block)
@block = block
end
def evaluate!
instance_eval(&@block)
end
def it(description, &block)
block.call
end
end
class Object
def should
DelayedAssertion.new(self)
end
end
class DelayedAssertion
def initialize(subject)
@subject = subject
end
def ==(other)
raise AssertionError unless @subject == other
end
end
class AssertionError < Exception
end
当ruby test_spec.rb
Run options:
# Running tests:
Finished tests in 0.004410s, 907.0295 tests/s, 453.5147 assertions/s.
4 tests, 2 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
默认情况下,它应该显示传球点,E代表错误,F代表失败。你可以发布你的输出,也许你的测试之一,包括你的test_helper? – DiegoSalazar 2014-09-29 16:52:45