Closed sormuras closed 6 years ago
Module scanning does not find any test classes: always "0 tests"
at https://travis-ci.org/forax/pro/builds/304437283#L700
Debugging...
The last "tester" run prints:
[...]
[tester] config {
modulefixer.moduleDependencyPath = [.\deps]
modulefixer.moduleDependencyFixerPath = .\target\deps\module-fixer
modulefixer.force = false
convention.javaLinkerImagePath = .\target\image
convention.javaModuleArtifactTestPath = .\target\test\artifact
convention.javaModuleTestPath = [.\src\test\java]
convention.javaModuleArtifactSourcePath = .\target\main\artifact
convention.javaHome = C:\Dev\github\forax\pro\target\pro
convention.javaModuleSourceResourcesPath = [.\src\main\resources]
convention.javaModuleExplodedTestPath = [.\target\test\exploded]
convention.javaMavenLocalRepositoryPath = .\target\deps\maven-local
convention.javaModuleExplodedSourcePath = [.\target\main\exploded]
convention.javaModuleDependencyPath = [.\deps]
convention.javaModuleDependencyFixerPath = .\target\deps\module-fixer
convention.javaModuleUberPath = .\target\uber
convention.javaModuleMergedTestPath = [.\target\test\merged]
convention.javaModuleTestResourcesPath = [.\src\test\resources]
convention.javaModuleUberExplodedPath = .\target\uber\exploded
convention.javaModuleSourcePath = [.\src\main\java]
resolver.moduleDependencyPath = [.\deps]
resolver.moduleTestPath = [.\src\test\java]
resolver.mavenLocalRepositoryPath = .\target\deps\maven-local
resolver.moduleSourcePath = [.\src\main\java]
linker.ignoreSigningInformation = false
linker.moduleArtifactSourcePath = .\target\main\artifact
linker.moduleDependencyPath = [.\deps]
linker.systemModulePath = C:\Dev\github\forax\pro\target\pro\jmods
linker.destination = .\target\image
linker.includeSystemJMODs = false
linker.stripDebug = false
linker.stripNativeCommands = false
linker.compressLevel = 0
uberpackager.moduleArtifactSourcePath = .\target\main\artifact
uberpackager.moduleDependencyPath = [.\deps]
uberpackager.moduleUberExplodedPath = .\target\uber\exploded
uberpackager.moduleUberPath = .\target\uber
tester.moduleDependencyPath = [.\deps]
tester.moduleExplodedTestPath = [plugins\tester\target\test\exploded]
tester.pluginDir = C:\Dev\github\forax\pro\target\pro\plugins
tester.timeout = 99
runner.modulePath = [.\target\main\artifact, .\deps, .\target\main\exploded]
runner.javaCommand = C:\Dev\github\forax\pro\target\pro\bin\java.exe
compiler.moduleDependencyPath = [.\deps]
compiler.moduleTestPath = [.\src\test\java]
compiler.moduleMergedTestPath = .\target\test\merged
compiler.moduleExplodedTestPath = .\target\test\exploded
compiler.release = 9
compiler.moduleExplodedSourcePath = .\target\main\exploded
compiler.moduleSourceResourcesPath = [.\src\main\resources]
compiler.moduleTestResourcesPath = [.\src\test\resources]
compiler.moduleSourcePath = [.\src\main\java]
pro.currentDir = .
pro.loglevel = debug
pro.pluginDir = C:\Dev\github\forax\pro\target\pro\plugins
pro.exitOnError = false
packager.moduleArtifactSourcePath = .\target\main\artifact
packager.moduleExplodedTestPath = [.\target\test\exploded]
packager.moduleExplodedSourcePath = [.\target\main\exploded]
packager.moduleArtifactTestPath = .\target\test\artifact
}
[tester] Testing com.github.forax.pro.plugin.tester...
Nov. 20, 2017 10:00:28 VORM. org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines
KONFIGURATION: Discovered TestEngines with IDs: [junit-jupiter (group ID: org.junit.jupiter, artifact ID: junit-jupiter-engine, version: DEVELOPMENT, location: jar:file:///C:/Dev/github/forax/pro/target/pro/plugins/tester/org.junit.jupiter.engine.jar!/org/junit/jupiter/engine/JupiterTestEngine.class)]
Nov. 20, 2017 10:00:28 VORM. org.junit.platform.launcher.core.ServiceLoaderTestExecutionListenerRegistry loadListeners
KONFIGURATION: Loaded TestExecutionListener instances: []
Nov. 20, 2017 10:00:28 VORM. org.junit.platform.launcher.core.DefaultLauncher discoverRoot
FEIN: Discovering tests during Launcher execution phase in engine 'junit-jupiter'.
Nov. 20, 2017 10:00:28 VORM. org.junit.platform.commons.util.ModuleUtils findAllClassesInModule
FEIN: Looking for classes in module: com.github.forax.pro.plugin.tester
Nov. 20, 2017 10:00:28 VORM. org.junit.platform.commons.util.ModuleUtils scan
FEIN: Scanning 0 module references: []
Nov. 20, 2017 10:00:28 VORM. org.junit.platform.commons.util.ModuleUtils scan
FEIN: Found 0 classes: []
Nov. 20, 2017 10:00:28 VORM. org.junit.jupiter.engine.extension.ExtensionRegistry createRegistryWithDefaultExtensions
FEINER: Registering default extensions: [org.junit.jupiter.engine.extension.DisabledCondition, org.junit.jupiter.engine.extension.RepeatedTestExtension, org.junit.jupiter.engine.extension.TestInfoParameterResolver, org.junit.jupiter.engine.extension.TestReporterParameterResolver]
[tester] Successfully tested com.github.forax.pro.plugin.tester: 0 tests in 31 ms
[pro] DONE ! elapsed time 100 ms
Seems like to the mapping from "module name" to "module reference" does not work as expected. The underlying reason might be located in the module layer setup built in TesterPlugin
:
private ClassLoader createTestClassLoader(TesterConf tester, Path testPath, String testModuleName) {
String pluginModuleName = TesterPlugin.class.getModule().getName(); // "com.github.forax.pro.plugin.tester"
List<String> rootNames = List.of(pluginModuleName, testModuleName);
StableList<Path> moduleFinderRoots = StableList
.of(testPath) // "target/test/exploded/[MODULE_NAME]
.append(tester.pluginDir().resolve(name())) // "[PRO_HOME]/plugins/tester"
.appendAll(tester.moduleExplodedTestPath()) // "target/test/exploded")
.appendAll(tester.moduleDependencyPath()); // "deps"
ModuleFinder finder = ModuleFinder.of(moduleFinderRoots.toArray(Path[]::new));
ModuleLayer bootModuleLayer = ModuleLayer.boot();
Configuration configuration = bootModuleLayer.configuration().resolve(finder, ModuleFinder.of(), rootNames);
ClassLoader parentLoader = ClassLoader.getSystemClassLoader();
ModuleLayer configuredLayer = bootModuleLayer.defineModulesWithOneLoader(configuration, parentLoader);
ClassLoader classLoader = configuredLayer.findLoader(pluginModuleName);
classLoader.setDefaultAssertionStatus(true); // -ea
return classLoader;
}
The paths look good to me, though...
[tester] Testing com.github.forax.pro.plugin.tester...
[tester] moduleFinderRoots: [C:\Dev\github\forax\pro\plugins\tester\target\test\exploded\com.github.forax.pro.plugin.tester, C:\Dev\github\forax\pro\target\pro\plugins\tester, plugins\tester\target\test\exploded, .\deps]
[tester] finder: jdk.internal.module.ModulePath@145f66e3
[tester] configuration: com.github.forax.pro.plugin.tester, org.junit.jupiter.api, org.junit.platform.commons, org.junit.platform.launcher, org.junit.jupiter.engine, org.opentest4j, org.junit.platform.engine
[tester] configuredLayer: org.junit.platform.engine, org.opentest4j, org.junit.jupiter.engine, org.junit.platform.launcher, org.junit.jupiter.api, org.junit.platform.commons, com.github.forax.pro.plugin.tester
The 5.1-SNAPSHOT version of JUnit introduces a "--scan-modules" option.
I wonder whether the tester plugin can make use of that new feature.
There's also an option that let you select individual modules:
--select-module <module>
This allows fine grained control to execute only tests declared in selected modules.