On 23 March 2016 at 07:21, Alan Bateman <alan.bate...@oracle.com> wrote:
> If they are in the same class loader and package as
> the code they are testing (the norm in Maven) then they need to compiled as
> if they are part of the module.

I struggle with that idea.

To me, tests are very definitely not part of the module. To me, they
are very clearly a separate module, one that uses the base module
(separate tree of code, separate dependencies, separate compilation
phase). In maven, there is even the possibility for one testing module
to depend on another testing module, a very useful feature.

The only special case about testing modules is that they are given
full access to everything in the underlying module. Forcing test code
to be embedded within the actual module just because the module design
doesn't allow any other option is flawed IMO.

Peter Levart's mail suggested one approach to provide the necessary
access rights for testing modules. But it still requires publication
package-by-package. Really, what is needed is a way to express that
the testing module is intimately connected, perhaps imposing a
requirement that both are loaded in the same classloader. eg.

module my.mod {
    fully-exposed-to my.mod.test;
}
module my.mod.test {
    requires my.mod;  // since other end specifies fully-exposed-to,
this gets full access
    requires junit;
}

Is this issue on the list of open issues?
http://openjdk.java.net/projects/jigsaw/spec/issues/

Stephen

Reply via email to