I have a custom annotation which is declared as below and have some implementation for this.
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface SampleTestCase {
public int caseID() default -1;
public int suiteId() default -1;
}
Now, I am trying to use this annotation and trying to send runtime parameters to it.
ConfigHelper config = new ConfigHelper();
int caseId = config.getTestCaseID();
@SampleTestCase(caseID=caseId,suiteId="Test")
public void testCaseOne(){
Assert.assertTrue(true);
}
Getting an error as "The value for annotation attribute TivoTestCase.caseID must be a constant expression".
Is there any way to pass dynamic parameters to an annotation other than this way??