I have an @interface annotation type like this -
public @interface someAnnotation {
String someVar() default "var_value";
}
I want to parametrize someVar on a Junit5 test similar to this
@ParametrizedTest
@ValueSource(strings = {"val1","val2"})
@someAnnotation(someVar = ??)
void theTestMethod(String s){
//test something
}
I want the value of s (that is provided by valueSource) to be loaded to someVar. Obviously something like this won't work -
@someAnnotation(someVar = s)
I have also tried using Test Extension by implementing BeforeEachCallback to get ExtensionContext using which someVar can be accessed but I have found no way to get ValueSource values or method parameters values from ExtensionContext. Is there any way to achieve this?