abstract class Spectator::Formatting::Formatter

Overview

Base class and interface used to notify systems of events. This is typically used for producing output from test results, but can also be used to send data to external systems.

All event methods are implemented as no-ops. To respond to an event, override its method. Every method receives a notification object containing information about the event.

Methods are called in this order:

  1. #start
  2. #example_started
  3. #example_finished
  4. #example_passed
  5. #example_pending
  6. #example_failed
  7. #stop
  8. #start_dump
  9. #dump_pending
  10. #dump_failures
  11. #dump_profile
  12. #dump_summary
  13. #close

Only one of the #example_passed, #example_pending, or #example_failed methods will be called after #example_finished, depending on the outcome of the test.

The "dump" methods are called after all tests that will run have run. They are provided summarized information.

Direct Known Subclasses

Defined in:

spectator/formatting/formatter.cr

Instance Method Summary

Instance methods inherited from class Object

should(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should(matcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should
, should_eventually(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_eventually, should_never(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_never, should_not(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should_not(matcher : Spectator::Matchers::NilMatcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should_not(matcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should_not

Instance Method Detail

def close #

Invoked at the end of the program. Allows the formatter to perform any cleanup and teardown.


[View source]
def dump_failures(_notification) #

Invoked after testing completes with a list of failed examples. This method will be called with an empty list if there were no failures. Called after #dump_pending and before #dump_summary. The notification will be an ExampleSummaryNotification type of object.


[View source]
def dump_pending(_notification) #

Invoked after testing completes with a list of pending examples. This method will be called with an empty list if there were no pending (skipped) examples. Called after #start_dump and before #dump_failures. The notification will be an ExampleSummaryNotification type of object.


[View source]
def dump_profile(_notification) #

Invoked after testing completes with profiling information. This method is only called if profiling is enabled. Called after #dump_failures and before #dump_summary.


[View source]
def dump_summary(_notification) #

Invoked after testing completes with summarized information from the test suite. Called after #dump_profile and before #close. The notification will be an SummaryNotification type of object.


[View source]
def example_error(_notification) #

Invoked after an example fails from an unexpected error. This is called right after #example_finished. The notification will be an ExampleNotification type of object.


[View source]
def example_failed(_notification) #

Invoked after an example fails. This is called right after #example_finished. The notification will be an ExampleNotification type of object.

NOTE Errors are normally considered failures, however #example_error is called instead if one occurs in an example.


[View source]
def example_finished(_notification) #

Invoked just after an example completes. This method is called once for every example. One of #example_passed, #example_pending or #example_failed will be called immediately after this method, depending on the example's result. The notification will be an ExampleNotification type of object.


[View source]
def example_passed(_notification) #

Invoked after an example completes successfully. This is called right after #example_finished. The notification will be an ExampleNotification type of object.


[View source]
def example_pending(_notification) #

Invoked after an example is skipped or marked as pending. This is called right after #example_finished. The notification will be an ExampleNotification type of object.


[View source]
def example_started(_notification) #

Invoked just before an example runs. This method is called once for every example. The notification will be an ExampleNotification type of object.


[View source]
def message(_notification) #

Called whenever the example or framework produces a message. This is typically used for logging. The notification will be a MessageNotification type of object.


[View source]
def start(_notification) #

This method is the first method to be invoked and will be called only once. It is called before any examples run. The notification will be a StartNotification type of object.


[View source]
def start_dump #

Invoked after all examples finished. Indicates that summarized report data is about to be produced. This method is called after #stop and before #dump_pending.


[View source]
def stop #

Invoked after all tests that will run have completed. When this method is called, it should be considered that the testing is done. Summary (dump) methods will be called after this.


[View source]