Package net.jqwik.api.lifecycle
Schnittstelle LifecycleContext
- Alle bekannten Unterschnittstellen:
ContainerLifecycleContext
,MethodLifecycleContext
,PropertyLifecycleContext
,TryLifecycleContext
@API(status=MAINTAINED,
since="1.4.0")
public interface LifecycleContext
Supertype of all lifecycle context interfaces.
- Siehe auch:
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibung<T extends Annotation>
Optional<T> findAnnotation
(Class<T> annotationClass) Retrieve an annotation if present at the current test element.<T extends Annotation>
List<T> findAnnotationsInContainer
(Class<T> annotationClass) Retrieve an annotation if present in the current element's containers.<T extends Annotation>
List<T> findRepeatableAnnotations
(Class<T> annotationClass) Retrieve a list of repeatable annotations if present at the current test element.label()
The elements label under which it shows up in test reports and IDEs.<T> T
newInstance
(Class<T> clazz) Create a new instance of aclazz
in the context of the property in which it is running.If the context refers to a class or a method the class or the method's class is returned, otherwiseOptional.empty()
If the context refers to a class or a method the class or method is returned, otherwiseOptional.empty()
reporter()
Get hold of test reporter for publishing additional information on a test container or method.resolveParameter
(Executable executable, int index) Resolve a parameter from a method in the context of the property in which it is running.void
wrapReporter
(Function<Reporter, Reporter> wrapper) Wrap reporter instance
-
Methodendetails
-
label
String label()The elements label under which it shows up in test reports and IDEs.- Gibt zurück:
- a String
-
optionalElement
Optional<AnnotatedElement> optionalElement()If the context refers to a class or a method the class or method is returned, otherwiseOptional.empty()
- Gibt zurück:
- an optional annotated element
-
optionalContainerClass
If the context refers to a class or a method the class or the method's class is returned, otherwiseOptional.empty()
- Gibt zurück:
- an optional annotated element
-
reporter
Reporter reporter()Get hold of test reporter for publishing additional information on a test container or method.- Gibt zurück:
- Current instance to test reporter
-
wrapReporter
Wrap reporter instance- Parameter:
wrapper
- Wrapping function that takes original reporter and returns a wrapped instance
-
findAnnotation
Retrieve an annotation if present at the current test element.- Typparameter:
T
- The annotation type- Parameter:
annotationClass
- The annotation type- Gibt zurück:
- instance of annotation type
-
findAnnotationsInContainer
Retrieve an annotation if present in the current element's containers. Search up the container stack. Closest container annotations come first in list.- Typparameter:
T
- The annotation type- Parameter:
annotationClass
- The annotation type- Gibt zurück:
- list of annotation objects
-
findRepeatableAnnotations
@API(status=MAINTAINED, since="1.7.4") <T extends Annotation> List<T> findRepeatableAnnotations(Class<T> annotationClass) Retrieve a list of repeatable annotations if present at the current test element.- Typparameter:
T
- The annotation type- Parameter:
annotationClass
- The annotation type- Gibt zurück:
- list of annotation objects
-
newInstance
Create a new instance of aclazz
in the context of the property in which it is running. Use this method, for example, when trying to instantiate a class retrieved from an annotation's attribute.The behaviour of this method differs from
Class.newInstance()
if the class to instantiate is a non-static member of the container class or even a nested container class.- Typparameter:
T
- The type to instantiate- Parameter:
clazz
- The class to instantiate- Gibt zurück:
- a freshly created instance of class
clazz
-
resolveParameter
Resolve a parameter from a method in the context of the property in which it is running.- Parameter:
executable
- The executable of the test container the parameter of which should be resolvedindex
- The parameter's position in a method - starting with 0.- Gibt zurück:
- supplier instance
- Löst aus:
CannotResolveParameterException
- if parameter cannot be resolved
-