mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Capture elapsed test time
This commit is contained in:
parent
e38fddb12a
commit
f4de0ffee9
4 changed files with 22 additions and 11 deletions
|
@ -7,8 +7,5 @@ module Spectator
|
|||
def errored? : Bool
|
||||
true
|
||||
end
|
||||
|
||||
def initialize(@example, @error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
module Spectator
|
||||
abstract class ExampleResult
|
||||
getter example : Example
|
||||
getter elapsed : Time::Span
|
||||
|
||||
abstract def passed? : Bool
|
||||
|
||||
protected def initialize(@example)
|
||||
protected def initialize(@example, @elapsed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,8 @@ module Spectator
|
|||
false
|
||||
end
|
||||
|
||||
def initialize(@example, @error)
|
||||
def initialize(example, elapsed, @error)
|
||||
super(example, elapsed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,12 +23,24 @@ module Spectator
|
|||
end
|
||||
|
||||
private def run_example(example)
|
||||
example.run
|
||||
SuccessfulExampleResult.new(example)
|
||||
rescue failure : ExpectationFailedError
|
||||
FailedExampleResult.new(example, failure)
|
||||
rescue ex
|
||||
ErroredExampleResult.new(example, ex)
|
||||
error = nil
|
||||
elapsed = Time.measure do
|
||||
begin
|
||||
example.run
|
||||
rescue failure : ExpectationFailedError
|
||||
error = failure
|
||||
rescue ex
|
||||
error = ex
|
||||
end
|
||||
end
|
||||
case error
|
||||
when Nil
|
||||
SuccessfulExampleResult.new(example, elapsed)
|
||||
when ExpectationFailedError
|
||||
FailedExampleResult.new(example, elapsed, error)
|
||||
else
|
||||
ErroredExampleResult.new(example, elapsed, error)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue