shard-spectator/src/spectator/example.cr

40 lines
1.2 KiB
Crystal
Raw Normal View History

require "./context_delegate"
require "./example_group"
require "./example_node"
require "./result"
require "./source"
2018-08-19 07:15:32 +00:00
module Spectator
# Standard example that runs a test case.
class Example < ExampleNode
# Indicates whether the example already ran.
getter? finished : Bool = false
# Retrieves the result of the last time the example ran.
getter! result : Result
# Creates the example.
# The *delegate* contains the test context and method that runs the test case.
# The *name* describes the purpose of the example.
# It can be a `Symbol` to describe a type.
# The *source* tracks where the example exists in source code.
# The example will be assigned to *group* if it is provided.
def initialize(@delegate : ContextDelegate,
2020-09-05 21:55:28 +00:00
name : String | Symbol? = nil, source : Source? = nil, group : ExampleGroup? = nil)
super(name, source, group)
end
# Executes the test case.
# Returns the result of the execution.
# The result will also be stored in `#result`.
def run : Result
raise NotImplementedError.new("#run")
end
# Exposes information about the example useful for debugging.
def inspect(io)
raise NotImplementedError.new("#inspect")
end
2018-08-19 07:15:32 +00:00
end
end