Class-level test annotation in JUnit 5

JodaStephen :

TestNG has a nice feature whereby the @Test annotation is added to the test class (instead of the test method). When the class is annotated, all public void-returning methods on the class are treated as test methods, as per the documentation.

@Test
public class Test1 {
  public void test1() {
  }
  public void test2() {
  }
}

Does JUnit 5 support a similar concept? If not, is there an extension that would allow Junit 5 to be extended?

(I can't find any discussion of class-level annotations wrt JUnit 5, maybe I've missed it. Having to annotate each method is error-prone, with a high chance of forgetting to annotate a method, and thus having the tests not run, creating a false sense of confidence.)

Update: Now raised as an issue.

Makoto :

No, this isn't available in JUnit 5.

For a time in JUnit 3, you could extend the TestCase class and then all of your methods which were prefixed with test* would be run automatically, but not only was that more subject to breakage, it's actually actively deprecated and modern frameworks won't run with those older-style tests.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=81816&siteId=1