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
|
def errored? : Bool
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(@example, @error)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
module Spectator
|
module Spectator
|
||||||
abstract class ExampleResult
|
abstract class ExampleResult
|
||||||
getter example : Example
|
getter example : Example
|
||||||
|
getter elapsed : Time::Span
|
||||||
|
|
||||||
abstract def passed? : Bool
|
abstract def passed? : Bool
|
||||||
|
|
||||||
protected def initialize(@example)
|
protected def initialize(@example, @elapsed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,8 @@ module Spectator
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(@example, @error)
|
def initialize(example, elapsed, @error)
|
||||||
|
super(example, elapsed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,12 +23,24 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
private def run_example(example)
|
private def run_example(example)
|
||||||
|
error = nil
|
||||||
|
elapsed = Time.measure do
|
||||||
|
begin
|
||||||
example.run
|
example.run
|
||||||
SuccessfulExampleResult.new(example)
|
|
||||||
rescue failure : ExpectationFailedError
|
rescue failure : ExpectationFailedError
|
||||||
FailedExampleResult.new(example, failure)
|
error = failure
|
||||||
rescue ex
|
rescue ex
|
||||||
ErroredExampleResult.new(example, 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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue