Class: Test::Unit::TestCase
- Inherits:
-
Object
- Object
- Test::Unit::TestCase
- Defined in:
- lib/test-unit-ext/metadata.rb,
lib/test-unit-ext/priority.rb
Class Method Summary collapse
- .bug(value, *tests) ⇒ Object
- .get_metadata(test_name) ⇒ Object
- .include(*args) ⇒ Object
- .inherited(sub) ⇒ Object
- .metadata(name, value, *tests) ⇒ Object
- .method_added(name) ⇒ Object
- .method_added_without_metadata ⇒ Object
- .method_added_without_priority ⇒ Object
- .need_to_run?(test_name) ⇒ Boolean
- .priority(name, *tests) ⇒ Object
- .set_metadata(test_name, metadata) ⇒ Object
Instance Method Summary collapse
- #metadata ⇒ Object
- #need_to_run? ⇒ Boolean
- #run(result, &block) ⇒ Object
- #run_without_metadata ⇒ Object
- #run_without_priority ⇒ Object
Class Method Details
.bug(value, *tests) ⇒ Object
27 28 29 |
# File 'lib/test-unit-ext/metadata.rb', line 27 def bug(value, *tests) (:bug, value, *tests) end |
.get_metadata(test_name) ⇒ Object
39 40 41 42 43 |
# File 'lib/test-unit-ext/metadata.rb', line 39 def (test_name) test_name = normalize_test_name(test_name) @metadata ||= {} @metadata[test_name] end |
.include(*args) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/test-unit-ext/priority.rb', line 16 def include(*args) args.reverse_each do |mod| super(mod) next unless defined?(@priority_initialized) mod.instance_methods(false).each do |name| set_priority(name) end end end |
.inherited(sub) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/test-unit-ext/priority.rb', line 9 def inherited(sub) super sub.instance_variable_set("@priority_initialized", true) sub.instance_variable_set("@priority_table", {}) sub.priority :normal end |
.metadata(name, value, *tests) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/test-unit-ext/metadata.rb', line 16 def (name, value, *tests) @current_metadata ||= {} if tests.empty? @current_metadata[name] = value else tests.each do |test| (test, {name => value}) end end end |
.method_added(name) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/test-unit-ext/metadata.rb', line 8 def method_added(name) (name) if defined?(@current_metadata) (name, @current_metadata) @current_metadata = {} end end |
.method_added_without_metadata ⇒ Object
7 |
# File 'lib/test-unit-ext/metadata.rb', line 7 alias_method :method_added_without_metadata, :method_added |
.method_added_without_priority ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/test-unit-ext/priority.rb', line 26 def method_added(name) (name) if defined?(@current_metadata) (name, @current_metadata) @current_metadata = {} end end |
.need_to_run?(test_name) ⇒ Boolean
47 48 49 50 51 52 |
# File 'lib/test-unit-ext/priority.rb', line 47 def need_to_run?(test_name) normalized_test_name = normalize_test_name(test_name) priority = @priority_table[normalized_test_name] return true unless priority __send__(priority_check_method_name(priority), test_name) end |
.priority(name, *tests) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/test-unit-ext/priority.rb', line 32 def priority(name, *tests) singleton_class = (class << self; self; end) priority_check_method = priority_check_method_name(name) unless singleton_class.private_method_defined?(priority_check_method) raise ArgumentError, "unknown priority: #{name}" end if tests.empty? @current_priority = name else tests.each do |test| set_priority(test, name) end end end |
.set_metadata(test_name, metadata) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/test-unit-ext/metadata.rb', line 31 def (test_name, ) return if .empty? test_name = normalize_test_name(test_name) @metadata ||= {} @metadata[test_name] ||= {} @metadata[test_name] = @metadata[test_name].merge() end |
Instance Method Details
#metadata ⇒ Object
51 52 53 |
# File 'lib/test-unit-ext/metadata.rb', line 51 def self.class.(@method_name) || {} end |
#need_to_run? ⇒ Boolean
92 93 94 |
# File 'lib/test-unit-ext/priority.rb', line 92 def need_to_run? !previous_test_success? or self.class.need_to_run?(@method_name) end |
#run(result, &block) ⇒ Object
47 48 49 |
# File 'lib/test-unit-ext/metadata.rb', line 47 def run(result, &block) (TestResultMetadataSupport.new(result, self), &block) end |
#run_without_metadata ⇒ Object
46 |
# File 'lib/test-unit-ext/metadata.rb', line 46 alias_method :run_without_metadata, :run |
#run_without_priority ⇒ Object
96 97 98 |
# File 'lib/test-unit-ext/priority.rb', line 96 def run(result, &block) (TestResultMetadataSupport.new(result, self), &block) end |