-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added experimental MethodLifecycleContext interface
- Loading branch information
Showing
6 changed files
with
72 additions
and
78 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
api/src/main/java/net/jqwik/api/lifecycle/MethodLifecycleContext.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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package net.jqwik.api.lifecycle; | ||
|
||
import java.lang.reflect.*; | ||
import java.util.*; | ||
|
||
import org.apiguardian.api.*; | ||
|
||
import static org.apiguardian.api.API.Status.*; | ||
|
||
/** | ||
* The context information for all method-based lifecyle contexts. | ||
* | ||
* @see PropertyLifecycleContext | ||
* @see TryLifecycleContext | ||
*/ | ||
@API(status = EXPERIMENTAL, since = "1.7.4") | ||
public interface MethodLifecycleContext extends LifecycleContext { | ||
|
||
/** | ||
* The method that defines the current property or example. | ||
* | ||
* @return a Method instance | ||
*/ | ||
@API(status = MAINTAINED, since = "1.4.0") | ||
Method targetMethod(); | ||
|
||
/** | ||
* The container class in which the current property method is running. | ||
* | ||
* <p> | ||
* Most of the time that's also the defining class. It differs when | ||
* running properties that are defined in a super class or an implemented interface. | ||
* </p> | ||
* | ||
* @return a Class instance | ||
*/ | ||
@API(status = MAINTAINED, since = "1.4.0") | ||
Class<?> containerClass(); | ||
|
||
/** | ||
* The current instance of the property's container class. | ||
* There is exactly one instance per property method. | ||
* | ||
* @return an instance of the container class in which the current property method is running | ||
*/ | ||
@API(status = MAINTAINED, since = "1.4.0") | ||
Object testInstance(); | ||
|
||
/** | ||
* The list of the current instance of the property's container class and all its outer objects | ||
* if it is in a nested class. | ||
* The result of {@linkplain #testInstance()} is the last in the list. | ||
* | ||
* @return List of instances starting from outer-most to inner-most class | ||
*/ | ||
@API(status = MAINTAINED, since = "1.5.4") | ||
List<Object> testInstances(); | ||
|
||
} |
43 changes: 1 addition & 42 deletions
43
api/src/main/java/net/jqwik/api/lifecycle/PropertyLifecycleContext.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
37 changes: 1 addition & 36 deletions
37
api/src/main/java/net/jqwik/api/lifecycle/TryLifecycleContext.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,48 +1,13 @@ | ||
package net.jqwik.api.lifecycle; | ||
|
||
import java.lang.reflect.*; | ||
|
||
import org.apiguardian.api.*; | ||
|
||
import net.jqwik.api.*; | ||
|
||
import static org.apiguardian.api.API.Status.*; | ||
|
||
/** | ||
* The context information of a single try of a property. | ||
*/ | ||
@API(status = MAINTAINED, since = "1.4.0") | ||
public interface TryLifecycleContext extends LifecycleContext { | ||
|
||
/** | ||
* The method that defines the current property or example. | ||
* | ||
* @return a Method instance | ||
*/ | ||
Method targetMethod(); | ||
|
||
/** | ||
* The container class in which the current property method is running. | ||
* | ||
* <p> | ||
* Most of the time that's also the defining class. It differs when | ||
* running properties that are defined in a super class or an implemented interface. | ||
* </p> | ||
* | ||
* @return a Class instance | ||
*/ | ||
Class<?> containerClass(); | ||
|
||
/** | ||
* The current instance of the property's container class. | ||
* There is exactly one instance per property method. | ||
* | ||
* <p> | ||
* Mind that all tries of a property <em>share the same test instance</em>. | ||
* </p> | ||
* | ||
* @return an instance of the container class in which the current property method is running | ||
*/ | ||
Object testInstance(); | ||
public interface TryLifecycleContext extends MethodLifecycleContext { | ||
|
||
} |
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