2014-09-29 48 views
0

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

默认情况下,它应该显示传球点,E代表错误,F代表失败。你可以发布你的输出,也许你的测试之一,包括你的test_helper? – DiegoSalazar 2014-09-29 16:52:45

回答

0

运行的结果,我认为一个TestCase代表单个测试。它不负责运行或提供UI。我认为你正在寻找一名“亚军”。 minitest,你可以简单地require 'minitest/autorun',并在Test::Unit(这已弃用),你可能会以某种方式使用Test::Unit::Runner。我使用rspec,所以我不知道确切的细节,但Test :: Unit和minitest都包含在ruby stdlib中,因此文档应该很容易找到。

0

我升级了'测试单元',我收回了点。在写这个版本的时候是3.1.8。

相关问题