Re: Surefire and Java Modules

Mirko Friedenhagen <[email protected]> Fri, 10 Apr 2026 11:27:05 +0200
Newsgroups gmane.comp.jakarta.turbine.maven.user
Message-ID <[email protected]>
=EF=BB=BF
Mit freundlichen Gr=C3=BC=C3=9Fen
Mirko Friedenhagen
=E2=80=94



Mit freundlichen Gr=C3=BC=C3=9Fen
Mirko Friedenhagen
=E2=80=94=20

> Am 09.04.2026 um 23:54 schrieb Martin Desruisseaux via users <users@maven.=
apache.org>:
>=20
> =EF=BB=BFHello Jochen
>=20
>> Le 09/04/2026 =C3=A0 23:30, Jochen Wiedmann a =C3=A9crit :
>> My impression is, that unit tests in src/test/java, as executed by
>> surefire, share a module with the code, that's being tested (in
>> src/main/java). Which is good, in general, because it permits access
>> to the implementation details, that are being tested. Is that correct,
>> so far?
>=20
> Correct, in order to access package-private classes or members, the test c=
ode need to be in the same package, which require that the test code is also=
 in the same module. For adding test code to a module, the `--patch-module` o=
ption must be used both at compile time and at test runtime.
>=20
>=20
>> However, there is another point: It seems important to me, that access
>> from external modules to my own works as expected. I would like to
>> ensure that by running some tests as a separate module. Is that a
>> valid concern? Is that possible, and how?
>=20
> It is not possible to access package-private classes or members from anoth=
er module, except by using the `--patch-module` option. But that option shou=
ld be used only for testing purposes or as temporary patches, not in product=
ion.
Hi Martin,

I understood Jochen wanted to test whether the module separation does work. D=
o you know whether failsafe could be used for this?

Mit freundlichen Gr=C3=BC=C3=9Fen
Mirko Friedenhagen=