junit5.eclass

Name

junit5.eclass -- Experimental eclass to add support for testing on the JUnit Platform

Description

This eclass runs tests on the JUnit Platform (which is a JUnit 5 sub-project) during the src_test phase. It is an experimental eclass whose code should eventually be merged into java-utils-2.eclass and/or java-pkg-simple.eclass when it is mature.

Supported EAPIs

8 9

Exported Phases

  • pkg_setup

  • src_test

Functions

ejunit5 [-cp <classpath>|-classpath <classpath>] <classes>

Using the specified classpath, launches a JVM instance to run the specified test classes by invoking the JUnit Platform's ConsoleLauncher.

This function's interface is consistent with the existing 'ejunit' and 'ejunit4' functions in java-utils-2.eclass.

Variables

JAVA_TEST_SELECTION_METHOD ?= traditional

A string that represents the method to discover and select test classes to run on the JUnit Platform. These values are accepted:

  • "traditional" (default): Use the same method as java-pkg-simple.eclass.

  • "scan-classpath": Rely on the JUnit Platform's ConsoleLauncher's '--scan-classpath' option to discover tests, and run these discovered tests. JAVA_TEST_RUN_ONLY and JAVA_TEST_EXCLUDES are both honored.

  • "scan-classpath+pattern": Rely on the JUnit Platform's ConsoleLauncher's '--scan-classpath' option to discover tests, but also select the same tests that java-pkg-simple.eclass would select from the discovered tests. JAVA_TEST_RUN_ONLY and JAVA_TEST_EXCLUDES are both honored.

  • "console-args": Do not perform any test discovery or test selection; instead, pass the JAVA_JUNIT_CONSOLE_ARGS variable's value to the JUnit Platform's ConsoleLauncher. In this case, JAVA_JUNIT_CONSOLE_ARGS should contain arguments to ConsoleLauncher that select tests to run. Neither JAVA_TEST_RUN_ONLY nor JAVA_TEST_EXCLUDES is honored.

If multiple values separated by white-space characters are included, then this eclass will use every method to run tests once and print a comparison of the number of tests each method ran at the end. However, this should only be used in development for comparing and evaluating the methods.

Example values:

JAVA_TEST_SELECTION_METHOD="scan-classpath+pattern"
JAVA_TEST_SELECTION_METHOD="traditional scan-classpath"
JAVA_JUNIT_CONSOLE_ARGS

Extra arguments to pass to JUnit Platform's ConsoleLauncher only when JAVA_TEST_SELECTION_METHOD contains "console-args". Any white-space character in this variable's value will separate tokens into different arguments.

JAVA_JUNIT_CONSOLE_COLOR (USER VARIABLE)

If this variable's value is not empty, enable color in the JUnit Platform's ConsoleLauncher's output.

Authors

Yuan Liao <liaoyuan@gmail.com>

Maintainers

java@gentoo.org

Reporting Bugs

Please report bugs via https://bugs.gentoo.org/