The class having
@Info(name = "ABC", version = "1.1.1")
public class Test implements TestPlugin{
}
Where @Info is @interface annotation
I want to write junit test case to verify its @info name and version, what i have passed.
You can use reflection for this:
Annotation annotation = Test.class.getAnnotation(Info.class);
if(annotation instanceof Info){
Info info = (Info) annotation;
assertEquals("ABC", info.name());
assertEquals("1.1.1", info.version());
} else {
fail("Did not find annotation");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With