forked from spockframework/spock
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
87 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
spock-core/src/main/java/org/spockframework/runtime/extension/IBlockListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,43 @@ | ||
package org.spockframework.runtime.extension; | ||
|
||
import org.spockframework.runtime.model.BlockInfo; | ||
import org.spockframework.runtime.model.ErrorInfo; | ||
import org.spockframework.runtime.model.IterationInfo; | ||
import org.spockframework.util.Beta; | ||
|
||
/** | ||
* Listens to block events during the execution of a feature. | ||
* <p> | ||
* Usually used in conjunction with {@link org.spockframework.runtime.IRunListener}. | ||
* Currently, only extensions can register listeners. | ||
* They do so by invoking {@link org.spockframework.runtime.model.FeatureInfo#addBlockListener(IBlockListener)}. | ||
* It is preferred to use a single instance of this. | ||
* <p> | ||
* It is discouraged to perform long-running operations in the listener methods, | ||
* as they are called during the execution of the specification. | ||
* It is discouraged to perform any side effects affecting the tests. | ||
* <p> | ||
* When an exception is thrown in a block, the {@code blockExited} will not be called for that block. | ||
* If a cleanup block is present the cleanup block listener methods will still be called. | ||
* | ||
* @see org.spockframework.runtime.IRunListener | ||
* @author Leonard Brünings | ||
* @since 2.4 | ||
*/ | ||
@Beta | ||
public interface IBlockListener { | ||
|
||
/** | ||
* Called when a block is entered. | ||
*/ | ||
default void blockEntered(IterationInfo iterationInfo, BlockInfo blockInfo) {} | ||
|
||
/** | ||
* Called when a block is exited. | ||
* <p> | ||
* This method is not called if an exception is thrown in the block. | ||
* The block that was active will be available in the {@link org.spockframework.runtime.model.IErrorContext} | ||
* and can be observed via {@link org.spockframework.runtime.IRunListener#error(ErrorInfo)}. | ||
*/ | ||
default void blockExited(IterationInfo iterationInfo, BlockInfo blockInfo) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters