Class: Micron::Runner::Method
- Inherits:
-
Object
- Object
- Micron::Runner::Method
- Defined in:
- lib/micron/runner/method.rb
Instance Attribute Summary collapse
-
#assertions ⇒ Object
Returns the value of attribute assertions.
-
#clazz ⇒ Object
readonly
Returns the value of attribute clazz.
-
#durations ⇒ Object
readonly
Returns the value of attribute durations.
-
#ex ⇒ Object
Returns the value of attribute ex.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#passed ⇒ Object
Returns the value of attribute passed.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(clazz, name) ⇒ Method
constructor
A new instance of Method.
- #passed? ⇒ Boolean
- #run ⇒ Object
-
#run_test ⇒ Object
Execute the actual test.
- #skipped? ⇒ Boolean
- #status ⇒ Object
-
#total_duration ⇒ Object
Get the total duration of this method’s run (setup + runtime + teardown).
Constructor Details
#initialize(clazz, name) ⇒ Method
12 13 14 15 16 17 18 19 |
# File 'lib/micron/runner/method.rb', line 12 def initialize(clazz, name) @passed = false @durations = {} @assertions = 0 @clazz = clazz @name = name end |
Instance Attribute Details
#assertions ⇒ Object
Returns the value of attribute assertions.
9 10 11 |
# File 'lib/micron/runner/method.rb', line 9 def assertions @assertions end |
#clazz ⇒ Object (readonly)
Returns the value of attribute clazz.
8 9 10 |
# File 'lib/micron/runner/method.rb', line 8 def clazz @clazz end |
#durations ⇒ Object (readonly)
Returns the value of attribute durations.
8 9 10 |
# File 'lib/micron/runner/method.rb', line 8 def durations @durations end |
#ex ⇒ Object
Returns the value of attribute ex.
9 10 11 |
# File 'lib/micron/runner/method.rb', line 9 def ex @ex end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/micron/runner/method.rb', line 8 def name @name end |
#passed ⇒ Object
Returns the value of attribute passed.
9 10 11 |
# File 'lib/micron/runner/method.rb', line 9 def passed @passed end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
10 11 12 |
# File 'lib/micron/runner/method.rb', line 10 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
10 11 12 |
# File 'lib/micron/runner/method.rb', line 10 def stdout @stdout end |
Instance Method Details
#failed? ⇒ Boolean
68 69 70 |
# File 'lib/micron/runner/method.rb', line 68 def failed? !passed end |
#passed? ⇒ Boolean
60 61 62 |
# File 'lib/micron/runner/method.rb', line 60 def passed? passed end |
#run ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/micron/runner/method.rb', line 21 def run out, err = Micron.capture_io { run_test() } @stdout = out @stderr = err nil end |
#run_test ⇒ Object
Execute the actual test
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/micron/runner/method.rb', line 31 def run_test t = nil begin t = clazz.create if t.respond_to? :micron_method= then t.micron_method = self # minitest compat shim end time(:setup) { setup(t) } time(:runtime) { t.send(name) } self.passed = true rescue *PASSTHROUGH_EXCEPTIONS raise rescue Exception => e self.passed = false self.ex = ExceptionInfo.new(e) ensure self.assertions += t._assertions if not t.nil? time(:teardown) { teardown(t) if not t.nil? } end end |
#skipped? ⇒ Boolean
64 65 66 |
# File 'lib/micron/runner/method.rb', line 64 def skipped? ex.kind_of?(Skip) end |
#status ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/micron/runner/method.rb', line 72 def status if skipped? then "skip" elsif passed? then "pass" else "fail" end end |
#total_duration ⇒ Object
Get the total duration of this method’s run (setup + runtime + teardown)
83 84 85 86 87 |
# File 'lib/micron/runner/method.rb', line 83 def total_duration n = 0.0 @durations.values.each{ |d| n += d } n end |