JUNIT5.ECLASS

Section: eclass-manpages (5)
Updated: Aug 2025
Index Return to Main Contents

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

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.

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/

FILES

junit5.eclass

SEE ALSO

ebuild(5)
https://gitweb.gentoo.org/repo/gentoo.git/log/eclass/junit5.eclass


Index

NAME
DESCRIPTION
SUPPORTED EAPIS
FUNCTIONS
ECLASS VARIABLES
AUTHORS
MAINTAINERS
REPORTING BUGS
FILES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 03:27:01 GMT, August 22, 2025