-
Notifications
You must be signed in to change notification settings - Fork 4
Description
If a test suite's test folders do not contain a module-info.java it is at the moment always considered whitebox test suite. If there are no files at all, this leads to an error in Gradle as it will still try to run tests. This is, because the test task is re-configured to consider the main code and test code as one module. To prevent this, the current solution is to remove the JUnit dependencies that the test suite added. This is not an optimal solution. It breaks in cases where the test code is generated and not available at configuration time.
We should explore other options. Offending code:
java-module-testing/src/main/java/org/gradlex/javamodule/testing/JavaModuleTestingExtension.java
Lines 139 to 146 in e4616d9
| if (!testFolderExists) { | |
| // Remove the dependencies added by Gradle in case the test directory is missing. Then stop. This allows the use of 'useJUnitJupiter("")' without hassle. | |
| project.getConfigurations().getByName(suiteSourceSet.getImplementationConfigurationName(), implementation -> | |
| implementation.withDependencies(dependencySet -> dependencySet.removeIf(d -> "org.junit.jupiter".equals(d.getGroup()) && "junit-jupiter".equals(d.getName())))); | |
| project.getConfigurations().getByName(suiteSourceSet.getRuntimeOnlyConfigurationName(), runtimeOnly -> | |
| runtimeOnly.withDependencies(dependencySet -> dependencySet.removeIf(d -> "org.junit.platform".equals(d.getGroup()) && "junit-platform-launcher".equals(d.getName())))); | |
| return; | |
| } |