class TestUnitCollectorDescendant::TestCollect

Public Class Methods

name() click to toggle source
# File test-unit-3.3.4/test/collector/test-descendant.rb, line 36
def self.name
  "test-case1"
end

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File test-unit-3.3.4/test/collector/test-descendant.rb, line 30
def setup
  super

  @test_case1 = Class.new(Test::Unit::TestCase) do
    self.test_order = :alphabetic

    def self.name
      "test-case1"
    end

    def test_1
    end

    def test_2
    end
  end

  @test_case2 = Class.new(Test::Unit::TestCase) do
    self.test_order = :alphabetic

    def self.name
      "test-case2"
    end

    def test_0
    end
  end

  @no_test_case = Class.new do
    def self.name
      "no-test-case"
    end

    def test_4
    end
  end
end
test_0() click to toggle source
# File test-unit-3.3.4/test/collector/test-descendant.rb, line 54
def test_0
end
test_1() click to toggle source
# File test-unit-3.3.4/test/collector/test-descendant.rb, line 40
def test_1
end
test_2() click to toggle source
# File test-unit-3.3.4/test/collector/test-descendant.rb, line 43
def test_2
end
test_4() click to toggle source
# File test-unit-3.3.4/test/collector/test-descendant.rb, line 63
def test_4
end
test_basic() click to toggle source
# File test-unit-3.3.4/test/collector/test-descendant.rb, line 68
def test_basic
  assert_collect(full_suite("name"), "name")

  assert_collect(full_suite("name"), "name") do |collector|
    collector.filter = []
  end
end
test_filtered() click to toggle source
# File test-unit-3.3.4/test/collector/test-descendant.rb, line 76
def test_filtered
  assert_collect(empty_suite) do |collector|
    collector.filter = Proc.new {false}
  end

  assert_collect(full_suite) do |collector|
    collector.filter = Proc.new {true}
  end

  assert_collect(full_suite) do |collector|
    collector.filter = Proc.new {nil}
  end

  assert_collect(empty_suite) do |collector|
    collector.filter = [Proc.new {false}, Proc.new {true}]
  end

  assert_collect(empty_suite) do |collector|
    collector.filter = [Proc.new {true}, Proc.new {false}]
  end

  assert_collect(empty_suite) do |collector|
    collector.filter = [Proc.new {nil}, Proc.new {false}]
  end

  assert_collect(full_suite) do |collector|
    collector.filter = [Proc.new {nil}, Proc.new {true}]
  end

  expected = empty_suite
  suite1 = Test::Unit::TestSuite.new(@test_case1.name)
  suite1 << @test_case1.new("test_1")
  suite2 = Test::Unit::TestSuite.new(@test_case2.name)
  suite2 << @test_case2.new("test_0")
  expected << suite1 << suite2
  assert_collect(expected) do |collector|
    collector.filter = Proc.new do |test|
      ['test_1', 'test_0'].include?(test.method_name)
    end
  end

  suite1 = Test::Unit::TestSuite.new(@test_case1.name)
  suite1 << @test_case1.new("test_1")
  suite2 = Test::Unit::TestSuite.new(@test_case2.name)
  suite2 << @test_case2.new("test_0")
  assert_collect(empty_suite) do |collector|
    filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
               Proc.new {|test| test.method_name == 'test_0' ? true : nil},
               Proc.new {false}]
    collector.filter = filters
  end
end

Private Instance Methods

full_suite(name=nil) click to toggle source
# File test-unit-3.3.4/test/collector/test-descendant.rb, line 130
def full_suite(name=nil)
  sub_suite1 = Test::Unit::TestSuite.new(@test_case1.name)
  sub_suite1 << @test_case1.new('test_1')
  sub_suite1 << @test_case1.new('test_2')

  sub_suite2 = Test::Unit::TestSuite.new(@test_case2.name)
  sub_suite2 << @test_case2.new('test_0')

  suite = empty_suite(name)
  suite << sub_suite1
  suite << sub_suite2
  suite
end