Add docs to Report class

This commit is contained in:
Michael Miller 2019-02-12 23:13:03 -07:00
parent 6151912fa6
commit 6f08101828

View file

@ -1,46 +1,62 @@
module Spectator
# Outcome of all tests in a suite.
class Report
# Total length of time it took to execute the test suite.
# This includes examples, hooks, and framework processes.
getter runtime : Time::Span
@results : Array(Result)
# Creates the report.
# The `results` are from running the examples in the test suite.
# The `runtime` is the total time it took to execute the suite.
def initialize(results : Enumerable(Result), @runtime)
@results = results.to_a
end
# Number of examples.
def examples
@results.size
end
# Number of passing examples.
def successful_examples
@results.count(&.successful?)
end
# Number of failing examples (includes errors).
def failed_examples
@results.count(&.failed?)
end
# Returns a set of results for all failed examples.
def failures
@results.select(&.failed?)
end
# Number of examples that had errors.
def errored_examples
@results.count(&.errored?)
end
# Returns a set of results for all errored examples.
def errors
@results.select(&.errored?)
end
# Number of pending examples.
def pending_examples
@results.count(&.pending?)
end
# Length of time it took to run just example code.
# This does not include hooks,
# but it does include pre- and post-conditions.
def example_runtime
@results.map(&.elapsed).sum
end
# Length of time spent in framework processes and hooks.
def overhead_time
@runtime - example_runtime
end