## 1. JUnit 5

Much of the approach and helper classes described under JUnit4 apply when using JUnit5 however JUnit5 uses some slightly different class annotations when writing your tests. See the JUnit5 documentation for more details.

Create your test classes as per normal JUnit5 guidelines as shown in this example:

    class MyTest {
      @Test
      void streamSum() {
        assertTrue(Stream.of(1, 2, 3)
          .mapToInt(i -> i)
          .sum() > 5, () -> "Sum should be greater than 5")
      }

      @RepeatedTest(value=2, name = "{displayName} {currentRepetition}/{totalRepetitions}")
      void streamSumRepeated() {
        assert Stream.of(1, 2, 3).mapToInt(i -> i).sum() == 6
      }

      private boolean isPalindrome(s) { s == s.reverse()  }

      @ParameterizedTest                                                              (1)
      @ValueSource(strings = [ "racecar", "radar", "able was I ere I saw elba" ])
      void palindromes(String candidate) {
        assert isPalindrome(candidate)
      }

      @TestFactory
      def dynamicTestCollection() {[
        dynamicTest("Add test") { -> assert 1 + 1 == 2 },
        dynamicTest("Multiply Test", () -> { assert 2 * 3 == 6 })
      ]}
    }

1 | This test requires the additional `org.junit.jupiter:junit-jupiter-params` dependency if not already in your project.

You can run the tests in your IDE or build tool if it supports and is configured for JUnit5. If you run the above test in the GroovyConsole or via the `groovy` command, you will see a short text summary of the result of running the test:

    JUnit5 launcher: passed=8, failed=0, skipped=0, time=246ms

More detailed information is available at the `FINE` logging level. You can configure your logging to display such information or do it programmatically as follows:

    @BeforeAll
    static void init() {
      def logger = Logger.getLogger(LoggingListener.name)
      logger.level = Level.FINE
      logger.addHandler(new ConsoleHandler(level: Level.FINE))
    }