[junit]: IDEA-386776 JUnit version detection with customizable scope via registry key

(cherry picked from commit 07c6ae4bc0abecb3b2f09091a9f4b5b432ee437f)

IJ-CR-195055

GitOrigin-RevId: e33987390d856deb2974826e17eabd3b7752e535
This commit is contained in:
Aleksey Dobrynin
2026-03-16 11:19:22 +00:00
committed by intellij-monorepo-bot
parent 199a0c9301
commit 577faf357d
2 changed files with 11 additions and 1 deletions
@@ -160,6 +160,9 @@
<registryKey key="idea.test.graceful.shutdown.timeout.seconds"
defaultValue="600"
description="Timeout in seconds for the test runner to terminate gracefully after receiving a shutdown signal. A negative value disables the timeout, allowing unlimited wait."/>
<registryKey key="junit.version.detection.scope"
defaultValue="withDependenciesAndLibraries"
description="Scope used to detect the JUnit version in a module. Supported values: 'runtime' (module runtime), 'module' (module only), 'testsWithDependents' (tests with dependent modules), 'WithLibraries' (module with libraries), and 'withDependenciesAndLibraries' (module with dependencies and libraries; used by default)."/>
</extensions>
<extensionPoints>
@@ -640,7 +640,14 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState<JUnitCon
}
private static GlobalSearchScope getScopeForJUnit(@Nullable Module module, Project project) {
return module != null ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, true) : GlobalSearchScope.allScope(project);
if (module == null) return GlobalSearchScope.allScope(project);
return switch (Registry.stringValue("junit.version.detection.scope")) {
case "runtime" -> GlobalSearchScope.moduleRuntimeScope(module, true);
case "module" -> GlobalSearchScope.moduleScope(module);
case "testsWithDependents" -> GlobalSearchScope.moduleTestsWithDependentsScope(module);
case "WithLibraries" -> GlobalSearchScope.moduleWithLibrariesScope(module);
default -> GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, true);
};
}
public static GlobalSearchScope getScopeForJUnit(JUnitConfiguration configuration) {