jeudi 14 octobre 2021

How to get annotations of JUnit test suite class?

I have such an example of test suite class to run many test classes at once in JUnit 4.13.

@RunWith(Suite.class)
@SuiteClasses({
    FirstClassTest.class,
    SecondClassTest.class
})
@MyTestAnnotation
public class TestSuiteClass {
}

Currently, when I use this.getClass().getAnnotations() in test method, it returns annotations from test classes (i.e. FirstClassTest.class, SecondClassTest.class). I want to obtain annotation @MyTestAnnotation from TestSuiteClass.class. How can I achieve this?





Aucun commentaire:

Enregistrer un commentaire