Skip to content

Commit

Permalink
Add minimal documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard84 committed Nov 1, 2024
1 parent 55138de commit bd9e694
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/extensions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1377,3 +1377,25 @@ It is primarily for framework developers who want to provide a default value for
Or users of a framework that doesn't provide default values for their special types.

If you want to change the default response behavior for `Stub` have a look at <<interaction_based_testing.adoc#ALaCarteMocks,A la Carte Mocks>> and how to use your own `org.spockframework.mock.IDefaultResponse`.

=== Listeners

Extensions can register listeners to receive notifications about the progress of the test run.
These listeners are intended to be used for reporting, logging, or other monitoring purposes.
They are not intended to modify the test run in any way.
You can register the same listener instance on multiple specifications or features.
Please consult the JavaDoc of the respective listener interfaces for more information.

==== `IRunListener`

The `org.spockframework.runtime.IRunListener` can be registered via `SpecInfo.addListener(IRunListener)` and will receive notifications about the progress of the test run of a single specification.

==== `IBlockListener`

The `org.spockframework.runtime.extension.IBlockListener` can be registered on a feature via, for example, `FeatureInfo.addBlockListener(IBlockListener)` and will receive notifications about the progress of the feature.

It will be called once when entering a block (`blockEntered`) and once when exiting a block (`blockExited`).

When an exception is thrown in a block, the `blockExited` will not be called for that block.
The failed block will be part of the `ErrorContext` in `ErrorInfo` that is passed to `IRunListener.error(ErrorInfo)`.
If a `cleanup` block is present the cleanup block listener methods will still be called.

0 comments on commit bd9e694

Please sign in to comment.