Currently I have the following code to test my class…
@RunWith(Suite.class)
@SuiteClasses( { MyClass.class, MyNewClass } )
public class AllTests {
public static void suite() {
}
}
What I’d like to do would be the following, but it’s syntactically incorrect – what would be the correct format?…
Class<?>[] classArray = new Class<?>[] {
MyClass.class, MyNewClass.class
};
@RunWith(Suite.class)
@SuiteClasses( classArray )
public class AllTests {
public static void suite() {
}
}
Unfortunately you can’t. Annotations need to take compile-time constants, so you have to use
{ MyClass.class, MyNewClass.class }.