-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle skipped test cases in JUnit output
Split test case element into different types.
- Loading branch information
1 parent
265a132
commit 8a7042c
Showing
5 changed files
with
101 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require "../../assertion_failed" | ||
require "./test_case" | ||
|
||
module Spectator::Formatters::JUnit | ||
struct FailedTestCase < TestCase | ||
def initialize(*, | ||
name : String, | ||
class_name : String, | ||
assertions : Int32? = nil, | ||
time : Time::Span? = nil, | ||
file : String? = nil, | ||
line : Int32? = nil, | ||
@error : Exception) | ||
super(name: name, class_name: class_name, assertions: assertions, time: time, file: file, line: line) | ||
end | ||
|
||
private def has_inner_content? : Bool | ||
true | ||
end | ||
|
||
private def print_inner(io : IO, indent : Int) : Nil | ||
error = @error | ||
type = error.is_a?(AssertionFailed) ? "failure" : "error" | ||
print_indent(io, indent) | ||
io << '<' << type | ||
write_xml_attribute(io, "message", error.message) | ||
write_xml_attribute(io, "type", error.class.name) | ||
|
||
if backtrace = error.backtrace? | ||
io.puts '>' | ||
HTML.escape(backtrace.join('\n'), io) | ||
io.puts | ||
print_indent(io, indent) | ||
io << "</" << type | ||
io.puts '>' | ||
else | ||
io.puts " />" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require "./test_case" | ||
|
||
module Spectator::Formatters::JUnit | ||
struct PassedTestCase < TestCase | ||
private def has_inner_content? : Bool | ||
false | ||
end | ||
|
||
private def print_inner(io : IO, indent : Int) : Nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "./test_case" | ||
|
||
module Spectator::Formatters::JUnit | ||
struct SkippedTestCase < TestCase | ||
def initialize(*, | ||
name : String, | ||
class_name : String, | ||
assertions : Int32? = nil, | ||
time : Time::Span? = nil, | ||
file : String? = nil, | ||
line : Int32? = nil, | ||
@skip_message : String? = nil) | ||
super(name: name, class_name: class_name, assertions: assertions, time: time, file: file, line: line) | ||
end | ||
|
||
private def has_inner_content? : Bool | ||
true | ||
end | ||
|
||
private def print_inner(io : IO, indent : Int) : Nil | ||
print_indent(io, indent) | ||
io << "<skipped" | ||
write_xml_attribute(io, "message", @skip_message) | ||
io.puts " />" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters