Class: Test::Unit::TestCase
- Inherits:
-
Object
- Object
- Test::Unit::TestCase
- Defined in:
- lib/ext/test/unit/testcase.rb
Class Method Summary collapse
-
.omit_if(message, *tests, &block) ⇒ Object
Omit (and don’t run setup/teardown) if block evalutes to true.
-
.omit_rest_if(message, &block) ⇒ Object
Omit remaining tests in class (and don’t run setup/teardown) if block evalutes to true.
-
.omit_unless(message, *tests, &block) ⇒ Object
Sugar for omit_if() { not .. }.
-
.pend(message, *tests) ⇒ Object
Mark test as pending (and don’t run setup/teardown).
-
.pend_rest_if(message) ⇒ Object
Mark remaining tests in class as pending (and don’t run setup/teardown).
Instance Method Summary collapse
-
#run_teardown(*args) ⇒ Object
We only run the #run_teardown if we’re not skipping this test, since teardown probably assumes setup() was called.
- #run_teardown_original ⇒ Object
-
#skipping_setup ⇒ Object
We pend/omit() before setup runs, so that we don’t have to run the test’s setup if we’re skipping it.
Class Method Details
.omit_if(message, *tests, &block) ⇒ Object
Omit (and don’t run setup/teardown) if block evalutes to true.
17 18 19 |
# File 'lib/ext/test/unit/testcase.rb', line 17 def omit_if(, *tests, &block) attribute(:fast_omit, [caller, , block], *tests) end |
.omit_rest_if(message, &block) ⇒ Object
Omit remaining tests in class (and don’t run setup/teardown) if block evalutes to true.
27 28 29 |
# File 'lib/ext/test/unit/testcase.rb', line 27 def omit_rest_if(, &block) attribute(:fast_omit, [caller, , block], {:keep => true}) end |
.omit_unless(message, *tests, &block) ⇒ Object
Sugar for omit_if() { not .. }
22 23 24 |
# File 'lib/ext/test/unit/testcase.rb', line 22 def omit_unless(, *tests, &block) attribute(:fast_omit, [caller, , Proc.new { |*args| not block.call(*args) }], *tests) end |
.pend(message, *tests) ⇒ Object
Mark test as pending (and don’t run setup/teardown)
5 6 7 8 9 |
# File 'lib/ext/test/unit/testcase.rb', line 5 def pend(, *tests) # We capture `caller` here so that we can give a better backtrace in # #pending_setup. attribute(:fast_pending, [caller, ], *tests) end |
.pend_rest_if(message) ⇒ Object
Mark remaining tests in class as pending (and don’t run setup/teardown)
12 13 14 |
# File 'lib/ext/test/unit/testcase.rb', line 12 def pend_rest_if() attribute(:fast_pending, [caller, ], {:keep => true}) end |
Instance Method Details
#run_teardown(*args) ⇒ Object
We only run the #run_teardown if we’re not skipping this test, since teardown probably assumes setup() was called.
58 59 60 |
# File 'lib/ext/test/unit/testcase.rb', line 58 def run_teardown(*args) run_teardown_original(*args) unless @fast_skipped end |
#run_teardown_original ⇒ Object
55 |
# File 'lib/ext/test/unit/testcase.rb', line 55 alias_method :run_teardown_original, :run_teardown |
#skipping_setup ⇒ Object
We pend/omit() before setup runs, so that we don’t have to run the test’s setup if we’re skipping it.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ext/test/unit/testcase.rb', line 35 def skipping_setup @fast_skipped = false bt = nil begin if self[:fast_pending] bt, = self[:fast_pending] pend() elsif self[:fast_omit] bt, , cond_block = self[:fast_omit] omit_if(cond_block.call(self), ) end rescue PendedError, OmittedError => e @fast_skipped = true # We reset the backtrace to point to the line where the pend/omit call was # originally made. e.set_backtrace(bt) if bt raise e end end |