mardi 3 mai 2016

Is there a simple way to make a JUnit suite of all the classes in a given package?

Using the Suite runner, you can make a Suite out of a given list of classes:

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({
  TestFeatureLogin.class,
  TestFeatureLogout.class,
  TestFeatureNavigate.class,
  TestFeatureUpdate.class
})

public class FeatureTestSuite {
  // the class remains empty,
  // used only as a holder for the above annotations
}

[Source]

Suppose that all those classes come from the same package - is there any way to do something like a @Suite.SuitePackage( ... ) to include them all and not have to update the Suite annotation when classes are added or removed?

Aucun commentaire:

Enregistrer un commentaire