You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature allows extension authors to register an `IBlockListener` for
a feature to observe the execution of a feature in more detail.
This surfaces some of Spock's idiosyncrasies, for example interaction
assertions are actually setup right before entering the preceding
`when`-block as well as being evaluated on leaving the `when`-block
before actually entering the `then`-block.
The only valid block description is a constant `String`, although some
users mistakenly try to use a dynamic `GString`. Using anything other
than a `String`, will be treated as a separate statement and thus ignored.
Expose `IErrorContext` in `ErrorInfo` to provide more information in
`IRunListener.error(ErrorInfo)` about where the error happened.
fixes#538fixes#111
Copy file name to clipboardExpand all lines: docs/extensions.adoc
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1380,3 +1380,26 @@ It is primarily for framework developers who want to provide a default value for
1380
1380
Or users of a framework that doesn't provide default values for their special types.
1381
1381
1382
1382
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`.
1383
+
1384
+
=== Listeners
1385
+
1386
+
Extensions can register listeners to receive notifications about the progress of the test run.
1387
+
These listeners are intended to be used for reporting, logging, or other monitoring purposes.
1388
+
They are not intended to modify the test run in any way.
1389
+
You can register the same listener instance on multiple specifications or features.
1390
+
Please consult the JavaDoc of the respective listener interfaces for more information.
1391
+
1392
+
==== `IRunListener`
1393
+
1394
+
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.
1395
+
1396
+
[#block-listener]
1397
+
==== `IBlockListener`
1398
+
1399
+
The `org.spockframework.runtime.extension.IBlockListener` can be registered on a feature via, `FeatureInfo.addBlockListener(IBlockListener)` and will receive notifications about the progress of the feature.
1400
+
1401
+
It will be called once when entering a block (`blockEntered`) and once when exiting a block (`blockExited`).
1402
+
1403
+
When an exception is thrown in a block, the `blockExited` will not be called for that block.
1404
+
The failed block will be part of the `ErrorContext` in `ErrorInfo` that is passed to `IRunListener.error(ErrorInfo)`.
1405
+
If a `cleanup` block is present the cleanup block listener methods will still be called.
0 commit comments