Skip to content

Whitebox: handling of empty test folder causes ClassNotFoundException if test code is generated #107

@jjohannes

Description

@jjohannes

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:

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions