我正在玩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