Annotation Interface ResourceLock
@ResourceLock
is used to declare that the annotated test class or test
method requires access to a shared resource identified by a key.
The resource key is specified via value()
. In addition,
mode()
allows you to specify whether the annotated test class or test
method requires READ_WRITE
or only
READ
access to the resource. In the former case,
execution of the annotated element will occur while no other test class or
test method that uses the shared resource is being executed. In the latter case,
the annotated element may be executed concurrently with other test classes or
methods that also require READ
access but not at the same time as any
other test that requires READ_WRITE
access.
This guarantee extends to lifecycle methods of a test class or method. For
example, if a test method is annotated with a @ResourceLock
annotation the "lock" will be acquired before any
@BeforeEach
methods are executed and released after all
@AfterEach
methods have been executed.
This annotation can be repeated to declare the use of multiple shared resources.
Since JUnit Jupiter 5.4, this annotation is inherited within class hierarchies.
- Since:
- 5.3
- See Also:
-
Required Element Summary
-
Optional Element Summary
-
Element Details
-
value
String valueThe resource key.- See Also:
-
mode
ResourceAccessMode modeThe resource access mode.Defaults to
READ_WRITE
.- See Also:
- Default:
READ_WRITE
-