3

I'm trying to create a custom rule in JUnit which only runs on test methods that I have a custom annotation on. The thing is I can't see a way to find out if the method wrapped in the Statement instance has the annotation set. I was thinking I could use reflection but how could I tell if the method in the Statement represents one of the annotated methods? Not really sure how to approach this. Thanks.

1 Answer 1

2

You can simply use the instance of the Description class passed into the Statement. See the javadoc for Description#getAnnotation().

For more information, please see my answer to Mark unit test as an expected failure in JUnit.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.