Class: Vapir::TestCase
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- Vapir::TestCase
show all
- Includes:
- Assertions
- Defined in:
- lib/vapir-common/testcase.rb
Constant Summary
collapse
- @@order =
:sequentially
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Assertions
#verify, #verify_equal, #verify_match
Constructor Details
#initialize(name) ⇒ TestCase
Returns a new instance of TestCase.
40
41
42
43
|
# File 'lib/vapir-common/testcase.rb', line 40
def initialize name
throw :invalid_test if name == :default_test && self.class == Vapir::TestCase
super
end
|
Class Attribute Details
.order ⇒ Object
Returns the value of attribute order.
45
46
47
|
# File 'lib/vapir-common/testcase.rb', line 45
def order
@order
end
|
.test_methods ⇒ Object
Returns the value of attribute test_methods.
45
46
47
|
# File 'lib/vapir-common/testcase.rb', line 45
def test_methods
@test_methods
end
|
Class Method Details
.default_order=(order) ⇒ Object
52
53
54
|
# File 'lib/vapir-common/testcase.rb', line 52
def default_order= order
@@order = order
end
|
.execute(order) ⇒ Object
82
83
84
|
# File 'lib/vapir-common/testcase.rb', line 82
def execute order
@order = order
end
|
.method_added(id) ⇒ Object
78
79
80
81
|
# File 'lib/vapir-common/testcase.rb', line 78
def method_added id
name = id.id2name
test_methods << name if name =~ /^test./
end
|
.sorted_test_methods ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/vapir-common/testcase.rb', line 55
def sorted_test_methods
case order
when :alphabetically then test_methods.sort
when :sequentially then test_methods
when :reversed_sequentially then test_methods.reverse
when :reversed_alphabetically then test_methods.sort.reverse
else raise ArgumentError, "Execute option not supported: #{@order}"
end
end
|
.suite ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/vapir-common/testcase.rb', line 64
def suite
suite = Test::Unit::TestSuite.new(name)
sorted_test_methods.each do |test|
catch :invalid_test do
suite << new(test)
end
end
if (suite.empty?)
catch :invalid_test do
suite << new(:default_test)
end
end
return suite
end
|