I have the following annotation to mark test code that should not be executed if a server does not listen on a host and port each specified in a properties file:
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(DisableOnServerNotListening.class)
public @interface DisabledOnServerNotListening
{
String propertyNameHost() default "host";
String propertyNamePort() default "port";
}
In a junit 5 ÈxecutionCondition
I want to look up the actual configured host/port values from the property file to decide if the test should be run (port is listening) or not
(port is not listening). Because there may be more than one host/port configuration in my tests I need to be flexible regarding property names. So how can I access the values of the annotation? Debugging shows that there is a field called testDescriptor
in ExtensionContext
, but it is not exposed for access.