Module: Test::Unit::Collector
- Included in:
- Descendant, Dir, Load, ObjectSpace, XML
- Defined in:
- lib/test/unit/collector.rb,
lib/test/unit/collector/dir.rb,
lib/test/unit/collector/xml.rb,
lib/test/unit/collector/load.rb,
lib/test/unit/collector/descendant.rb,
lib/test/unit/collector/objectspace.rb
Defined Under Namespace
Classes: Descendant, Dir, Load, ObjectSpace, XML
Instance Method Summary
collapse
Instance Method Details
#add_suite(destination, suite) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/test/unit/collector.rb', line 17
def add_suite(destination, suite)
to_delete = suite.tests.find_all do |test|
test.is_a?(TestCase) and !include?(test)
end
suite.delete_tests(to_delete)
destination << suite unless suite.empty?
end
|
#add_test_cases(suite, test_cases) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/test/unit/collector.rb', line 25
def add_test_cases(suite, test_cases)
children_map = {}
test_cases.each do |descendant_test_case|
parent = descendant_test_case.ancestors[1]
children_map[parent] ||= []
children_map[parent] << descendant_test_case
end
root_test_cases = children_map.keys - test_cases
root_test_cases.each do |root_test_case|
add_test_case(suite, root_test_case, children_map)
end
end
|
#filter=(filters) ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/test/unit/collector.rb', line 8
def filter=(filters)
@filters = case(filters)
when Proc
[filters]
when Array
filters
end
end
|
#include?(test) ⇒ Boolean
39
40
41
42
43
44
45
|
# File 'lib/test/unit/collector.rb', line 39
def include?(test)
return true if(@filters.empty?)
@filters.each do |filter|
return false if filter[test] == false
end
true
end
|
#initialize ⇒ Object
4
5
6
|
# File 'lib/test/unit/collector.rb', line 4
def initialize
@filters = []
end
|
#sort(suites) ⇒ Object
47
48
49
50
51
|
# File 'lib/test/unit/collector.rb', line 47
def sort(suites)
suites.sort_by do |suite|
[suite.priority, suite.name || suite.to_s]
end
end
|