-
In the Log4j project for each published artifact we have 4 sets of sources:
How would you perform testing in this case to detect problems in JPMS encapsulation? Currently we run all the tests on the classpath, mainly because:
I don't mind the classpath tests, since Unit tests should probably break encapsulation, but:
Since JUnit has probably one of the most evolved set of unit and integration tests, do you have any suggestions on how to solve this conundrum? Should we have an additional test-only Maven module for JPMS integration tests? How do you solve this kind of problems in your case? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hi Piotr, with "Log4j project" you are talking about (testing) those artifacts, right? org.apache.logging.log4j=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-api/3.0.0-alpha1/log4j-api-3.0.0-alpha1.jar
org.apache.logging.log4j.api.kotlin=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-api-kotlin/1.3.0/log4j-api-kotlin-1.3.0.jar
org.apache.logging.log4j.api.scala=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-api-scala_3/13.0.0/log4j-api-scala_3-13.0.0.jar
org.apache.logging.log4j.changelog=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-changelog/0.5.0/log4j-changelog-0.5.0.jar
org.apache.logging.log4j.core=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-core/3.0.0-alpha1/log4j-core-3.0.0-alpha1.jar
org.apache.logging.log4j.core.test=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-core-test/3.0.0-alpha1/log4j-core-test-3.0.0-alpha1.jar
org.apache.logging.log4j.jpl=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-jpl/3.0.0-alpha1/log4j-jpl-3.0.0-alpha1.jar
org.apache.logging.log4j.jul=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-jul/3.0.0-alpha1/log4j-jul-3.0.0-alpha1.jar
org.apache.logging.log4j.layout.template.json=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-layout-template-json/3.0.0-alpha1/log4j-layout-template-json-3.0.0-alpha1.jar
org.apache.logging.log4j.plugins=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-plugins/3.0.0-alpha1/log4j-plugins-3.0.0-alpha1.jar
org.apache.logging.log4j.plugins.test=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-plugins-test/3.0.0-alpha1/log4j-plugins-test-3.0.0-alpha1.jar
org.apache.logging.log4j.script=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-script/3.0.0-alpha1/log4j-script-3.0.0-alpha1.jar
org.apache.logging.log4j.test=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-api-test/3.0.0-alpha1/log4j-api-test-3.0.0-alpha1.jar
org.apache.logging.log4j.tojul=https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-to-jul/3.0.0-alpha1/log4j-to-jul-3.0.0-alpha1.jar |
Beta Was this translation helpful? Give feedback.
-
I wrote a blog about modular testing and most parts still apply today: https://sormuras.github.io/blog/2018-09-11-testing-in-the-modular-world Most parts? I don't like the
An integration test should be as close as possible to what your real users do. They would write something like: module org.example.app {
requires org.apache.logging.log4j;
} Thus, a test could read: module test.org.apache.logging.log4j {
requires org.apache.logging.log4j; // module under test
// ... here be more modules under test
requires test.fixtures; // contains rules and extensions required for testing
requires org.junit.jupiter; // for @Test and friends
requires org.assertj.core; // for its fluent assertion API
} |
Beta Was this translation helpful? Give feedback.
-
First, we prevent some problems to show up by sticking with official language and JDK support:
Then, we have an integration test compiling and running all example from the User Guide on the module path: https://github.com/junit-team/junit5/blob/main/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ModularUserGuideTests.java Additionally, the junit5-modular-world project from the samples repository acts as another "modular customer" scenario. |
Beta Was this translation helpful? Give feedback.
I wrote a blog about modular testing and most parts still apply today: https://sormuras.github.io/blog/2018-09-11-testing-in-the-modular-world
Most parts? I don't like the
module-info.test
approach as much as I did back then. Today, I prefer dedicatedmodule-info.java
files in test-only modules. So, yes to your question:An integration test should be as close as possible to what your real users do. They would write something like:
Thus, a test could read: