Building Java Modules with Blackbox Tests Sample
version 8.11.1
You can open this sample in an IDE that supports Gradle. |
This is an extension of this sample that adds blackbox integration tests.
There is also a new sample demonstrating how to use the incubating Test Suite Plugin in this scenario. |
Here, we add an additional source set integrationTest with a module-info.java
.
src
└── integrationTest
└── java
└── module-info.java
We effectively declare a second module that is only used for testing.
The module is open
, which means that it allows reflective access to its classes at runtime as required by JUnit’s test execution engine.
open module org.gradle.sample.integtest.utilities {
requires org.gradle.sample.utilities;
requires org.junit.jupiter.api;
}
This sample does not work in Eclipse when imported using Eclipse Buildship. This is due to a limitation in Eclipse that does not allow more than one module in one project. It you want to do blackbox testing in Eclipse, you should move the integration tests to separate subprojects. |
For more information, see Java Module support in the Java Library Plugin, Java Module support in the Application Plugin and testing Java Modules.