2018-08-31 05:38:20 +00:00
|
|
|
module Spectator
|
2018-12-12 18:48:08 +00:00
|
|
|
# Outcome of all tests in a suite.
|
2019-02-11 20:50:57 +00:00
|
|
|
class Report
|
2018-08-31 05:38:20 +00:00
|
|
|
getter runtime : Time::Span
|
|
|
|
|
2018-09-15 19:25:11 +00:00
|
|
|
@results : Array(Result)
|
2018-08-31 05:38:20 +00:00
|
|
|
|
2018-09-15 19:25:11 +00:00
|
|
|
def initialize(results : Enumerable(Result), @runtime)
|
2018-08-31 05:38:20 +00:00
|
|
|
@results = results.to_a
|
|
|
|
end
|
|
|
|
|
2018-09-15 19:51:07 +00:00
|
|
|
def examples
|
|
|
|
@results.size
|
|
|
|
end
|
|
|
|
|
2018-08-31 05:38:20 +00:00
|
|
|
def successful_examples
|
2018-09-15 19:51:07 +00:00
|
|
|
@results.count(&.successful?)
|
2018-08-31 05:38:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def failed_examples
|
2018-09-15 19:51:07 +00:00
|
|
|
@results.count(&.failed?)
|
|
|
|
end
|
|
|
|
|
2018-09-24 00:00:01 +00:00
|
|
|
def failures
|
|
|
|
@results.select(&.failed?)
|
|
|
|
end
|
|
|
|
|
2018-09-15 19:51:07 +00:00
|
|
|
def errored_examples
|
|
|
|
@results.count(&.errored?)
|
|
|
|
end
|
|
|
|
|
2018-09-24 00:00:01 +00:00
|
|
|
def errors
|
|
|
|
@results.select(&.errored?)
|
|
|
|
end
|
|
|
|
|
2018-09-15 19:51:07 +00:00
|
|
|
def pending_examples
|
|
|
|
@results.count(&.pending?)
|
2018-08-31 05:38:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def example_runtime
|
2018-09-28 00:49:01 +00:00
|
|
|
@results.map(&.elapsed).sum
|
2018-08-31 05:38:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def overhead_time
|
|
|
|
@runtime - example_runtime
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|