shard-spectator/src/spectator/test_suite_results.cr

49 lines
815 B
Crystal
Raw Normal View History

2018-08-31 05:38:20 +00:00
module Spectator
# Outcome of all tests in a suite.
class TestSuiteResults
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
@results.map(&.elapsed).sum
2018-08-31 05:38:20 +00:00
end
def overhead_time
@runtime - example_runtime
end
end
end