JUnit5 test classes and methods should not be silently ignored

Java pattern

JUnit silently ignores private classes and private methods, static methods, and methods returning a value without being a TestFactory.


Apply with the Grit CLI
grit apply junit_ignored_tests

Handles ignored tests and sub-classes

BEFORE
import org.junit.jupiter.api.Test;

class MyClassTest {
  @Test
  private void test1() {
    int i = 0;
  }
  @Test
  static void test2() {
    int i = 0;
  }
  @Test
  boolean test3() {
    int i = 0;
  }
  @Test
  public void test4() {
    int i = 0;
  }
  @Nested
  private class MyNestedClass {
    @Test
    void test() {
        int i = 0;
    }
  }
}
AFTER
import org.junit.jupiter.api.Test;

class MyClassTest {
  @Test
   void test1() {
    int i = 0;
  }
  @Test
   void test2() {
    int i = 0;
  }
  @Test
  void test3() {
    int i = 0;
  }
  @Test
  public void test4() {
    int i = 0;
  }
  @Nested
   class MyNestedClass {
    @Test
    void test() {
        int i = 0;
    }
  }
}