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
Returns a new instance of 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
74 75 76 |
# File 'lib/micron/runner/method.rb', line 74 def failed? !passed end |
#passed? ⇒ Boolean
66 67 68 |
# File 'lib/micron/runner/method.rb', line 66 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 59 60 61 62 63 64 |
# 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) } # run actual test method and measure runtime @runtime = Hitimes::Interval.now t.send(name) @durations[:runtime] = @runtime.stop self.passed = true rescue *PASSTHROUGH_EXCEPTIONS @durations[:runtime] = @runtime.stop if @runtime raise rescue Exception => e @durations[:runtime] = @runtime.stop if @runtime 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? } @runtime = nil end end |
#skipped? ⇒ Boolean
70 71 72 |
# File 'lib/micron/runner/method.rb', line 70 def skipped? ex.kind_of?(Skip) end |
#status ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/micron/runner/method.rb', line 78 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)
89 90 91 92 93 |
# File 'lib/micron/runner/method.rb', line 89 def total_duration n = 0.0 @durations.values.each{ |d| n += d } n end |