mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Cleanup top-level formatting code
This commit is contained in:
parent
3fbe6a2760
commit
ff20fbe232
1 changed files with 21 additions and 11 deletions
|
@ -7,7 +7,7 @@ module Spectator::Formatting
|
|||
private JUNIT_XML_FILE = "output.xml"
|
||||
|
||||
# Name of the top-level test suites block.
|
||||
private NAME = "AllTests"
|
||||
private NAME = "Spec"
|
||||
|
||||
# Creates the formatter.
|
||||
# By default, output is sent to STDOUT.
|
||||
|
@ -25,16 +25,7 @@ module Spectator::Formatting
|
|||
# Called when a test suite finishes.
|
||||
# The results from the entire suite are provided.
|
||||
def end_suite(report : Report)
|
||||
@xml.element("testsuites",
|
||||
tests: report.example_count,
|
||||
failures: report.failed_count,
|
||||
errors: report.error_count,
|
||||
time: report.runtime.total_seconds,
|
||||
name: NAME) do
|
||||
report.group_by(&.example.source.path).each do |path, results|
|
||||
JUnitTestSuite.new(path, results).to_xml(@xml)
|
||||
end
|
||||
end
|
||||
test_suites_block(report)
|
||||
@xml.end_document
|
||||
@xml.flush
|
||||
@io.close
|
||||
|
@ -48,5 +39,24 @@ module Spectator::Formatting
|
|||
# The result of the test is provided.
|
||||
def end_example(result : Result)
|
||||
end
|
||||
|
||||
# Creates the "testsuites" block in the XML.
|
||||
private def test_suites_block(report)
|
||||
@xml.element("testsuites",
|
||||
tests: report.example_count,
|
||||
failures: report.failed_count,
|
||||
errors: report.error_count,
|
||||
time: report.runtime.total_seconds,
|
||||
name: NAME) do
|
||||
add_test_suites(report)
|
||||
end
|
||||
end
|
||||
|
||||
# Adds all of the individual test suite blocks.
|
||||
private def add_test_suites(report)
|
||||
report.group_by(&.example.source.path).each do |path, results|
|
||||
JUnitTestSuite.new(path, results).to_xml(@xml)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue