mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Pass and output along reason for pending/skip result
This commit is contained in:
parent
8d73434e0b
commit
5a2a71ffe8
6 changed files with 17 additions and 9 deletions
|
@ -26,7 +26,7 @@ module Spectator
|
||||||
|
|
||||||
# Result of the last time the example ran.
|
# Result of the last time the example ran.
|
||||||
# Is pending if the example hasn't run.
|
# Is pending if the example hasn't run.
|
||||||
getter result : Result = PendingResult.new
|
getter result : Result = PendingResult.new(Time::Span::ZERO, "Example not run")
|
||||||
|
|
||||||
# Creates the example.
|
# Creates the example.
|
||||||
# An instance to run the test code in is given by *context*.
|
# An instance to run the test code in is given by *context*.
|
||||||
|
|
|
@ -78,8 +78,8 @@ module Spectator::Formatting::Components::JUnit
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds a skipped element to the test case node.
|
# Adds a skipped element to the test case node.
|
||||||
def pending(_result)
|
def pending(result)
|
||||||
@xml.element("skipped") # TODO: Populate message attribute with reason from result.
|
@xml.element("skipped", message: result.reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Spectator::Formatting::Components
|
||||||
|
|
||||||
# Content displayed on the second line of the block after the label.
|
# Content displayed on the second line of the block after the label.
|
||||||
private def subtitle
|
private def subtitle
|
||||||
"No reason given" # TODO: Get reason from result.
|
@result.reason
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prefix for the second line of the block.
|
# Prefix for the second line of the block.
|
||||||
|
|
|
@ -33,7 +33,11 @@ module Spectator::Formatting
|
||||||
# TODO: Skipped tests should report ok.
|
# TODO: Skipped tests should report ok.
|
||||||
@io << "not ok " << @counter << " - "
|
@io << "not ok " << @counter << " - "
|
||||||
@io << notification.example << " # TODO "
|
@io << notification.example << " # TODO "
|
||||||
@io.puts "No reason given" # TODO: Get reason from result.
|
|
||||||
|
# This should never be false.
|
||||||
|
if (result = notification.example.result).responds_to?(:reason)
|
||||||
|
@io.puts result.reason
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Invoked after an example fails.
|
# Invoked after an example fails.
|
||||||
|
|
|
@ -121,7 +121,7 @@ module Spectator
|
||||||
when ExpectationFailed
|
when ExpectationFailed
|
||||||
FailResult.new(elapsed, error, @expectations)
|
FailResult.new(elapsed, error, @expectations)
|
||||||
when ExamplePending
|
when ExamplePending
|
||||||
PendingResult.new(elapsed, @expectations)
|
PendingResult.new(elapsed, error.message || "No reason given", @expectations)
|
||||||
else
|
else
|
||||||
ErrorResult.new(elapsed, error, @expectations)
|
ErrorResult.new(elapsed, error, @expectations)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,10 +5,14 @@ module Spectator
|
||||||
# A pending result means the example is not ready to run yet.
|
# A pending result means the example is not ready to run yet.
|
||||||
# This can happen when the functionality to be tested is not implemented yet.
|
# This can happen when the functionality to be tested is not implemented yet.
|
||||||
class PendingResult < Result
|
class PendingResult < Result
|
||||||
|
# Reason the example was skipped or marked pending.
|
||||||
|
getter reason : String
|
||||||
|
|
||||||
# Creates the result.
|
# Creates the result.
|
||||||
# *elapsed* is the length of time it took to run the example.
|
# *elapsed* is the length of time it took to run the example.
|
||||||
def initialize(elapsed = Time::Span::ZERO, expectations = [] of Expectation)
|
# A *reason* for the skip/pending result can be specified.
|
||||||
super
|
def initialize(elapsed = Time::Span::ZERO, @reason = "No reason given", expectations = [] of Expectation)
|
||||||
|
super(elapsed, expectations)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calls the `pending` method on the *visitor*.
|
# Calls the `pending` method on the *visitor*.
|
||||||
|
@ -40,7 +44,7 @@ module Spectator
|
||||||
def to_json(json : JSON::Builder)
|
def to_json(json : JSON::Builder)
|
||||||
super
|
super
|
||||||
json.field("status", "pending")
|
json.field("status", "pending")
|
||||||
json.field("pending_message", "Not implemented") # TODO: Provide pending message.
|
json.field("pending_message", @reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue