mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add report for suite results
This commit is contained in:
parent
9d39bc80b1
commit
b8dcf35165
4 changed files with 40 additions and 8 deletions
27
src/spectator/report.cr
Normal file
27
src/spectator/report.cr
Normal file
|
@ -0,0 +1,27 @@
|
|||
module Spectator
|
||||
class Report
|
||||
getter runtime : Time::Span
|
||||
|
||||
@results : Array(ExampleResult)
|
||||
|
||||
def initialize(results : Enumerable(ExampleResult), @runtime)
|
||||
@results = results.to_a
|
||||
end
|
||||
|
||||
def successful_examples
|
||||
@results.select { |result| result.successful? }
|
||||
end
|
||||
|
||||
def failed_examples
|
||||
@results.select { |result| result.failed? }
|
||||
end
|
||||
|
||||
def example_runtime
|
||||
@results.map { |result| result.elapsed }.sum
|
||||
end
|
||||
|
||||
def overhead_time
|
||||
@runtime - example_runtime
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@ module Spectator
|
|||
module Reporters
|
||||
abstract class Reporter
|
||||
abstract def start_suite
|
||||
abstract def end_suite
|
||||
abstract def end_suite(report : Report)
|
||||
abstract def start_example(example : Example)
|
||||
abstract def end_example(result : ExampleResult)
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ module Spectator
|
|||
def start_suite
|
||||
end
|
||||
|
||||
def end_suite
|
||||
def end_suite(report : Report)
|
||||
puts
|
||||
end
|
||||
|
||||
|
|
|
@ -9,13 +9,18 @@ module Spectator
|
|||
end
|
||||
|
||||
def run : Nil
|
||||
results = [] of ExampleResult
|
||||
elapsed = Time.measure do
|
||||
@reporter.start_suite
|
||||
sorted_examples.each do |example|
|
||||
results = sorted_examples.map do |example|
|
||||
@reporter.start_example(example)
|
||||
result = run_example(example)
|
||||
run_example(example).tap do |result|
|
||||
@reporter.end_example(result)
|
||||
end
|
||||
@reporter.end_suite
|
||||
end
|
||||
end
|
||||
report = Report.new(results, elapsed)
|
||||
@reporter.end_suite(report)
|
||||
end
|
||||
|
||||
private def sorted_examples
|
||||
|
|
Loading…
Reference in a new issue