inline

On 12/13/2022 12:55 AM, John Hendrikx wrote:
Hi all,

I was wondering, is there a reason for the current test setup in the JavaFX code base?

Currently, tests are all stored under src/test/java under a special package name prefixed with "test". This is an (IMHO) unusual practice as normally tests mirror the same packages as their main classes to aid in testability. Testing a package private class is really hard because of this and requires the use of a shim -- the shims do mirror the same package hierarchy as the main classes.

Yes, this was a deliberate decision. We intentionally moved all tests out of the javafx.* hierarchy, primarily so that they could run in the unnamed module as part of the JDK 9 modularization and encapsulation effort, and added the shims to support whitebox testing. See https://bugs.openjdk.org/browse/JDK-8134760

A few questions related to this:

1) When testing a package private class in the com.sun.* hierarchy, is it okay to just make the class public (as it is already private API) so it can be tested without a shim?

In general, yes. If you need to do whitebox testing of a com.sun class, there is no need to use a shim (although I see that was done in a small number of cases).

2) Can at least the com.sun.* hierarchy be mirrored in src/test/java without the "test" package prefix?  Again, they're both non-public packages anyway.

No, that would require running those tests in the javafx.* module and is not the direction I would want to go.


3) Can we perhaps move all test classes to the package of their main counterparts, and do away with (probably all) shims?

No.

-- Kevin


--John


Reply via email to