Module (JavaTestConfigurationWithDiscoverySupport configuration, ConfigurationContext configurationContext, Pair<String, String> position, Project project, TestDiscoveryIndex testDiscoveryIndex) { final RunnerAndConfigurationSettings template = configurationContext.getRunManager().getConfigurationTemplate(getConfigurationFactory()); final Module predefinedModule = ((ModuleBasedConfiguration<?, ?>)template.getConfiguration()).getConfigurationModule().getModule(); if (predefinedModule != null) { return predefinedModule; } //potentially this set won't be big, it reflects modules from where user starts his tests final Collection<String> modules = testDiscoveryIndex.getTestModulesByMethodName(position.first, position.second, configuration.getTestFrameworkId()); if (modules.isEmpty()) return null; final List<Module> survivedModules = new ArrayList<>(); final ModuleManager moduleManager = ModuleManager.getInstance(project); for (String moduleName : modules) { final Module moduleByName = moduleManager.findModuleByName(moduleName); if (moduleByName != null) { survivedModules.add(moduleByName); } } if (survivedModules.isEmpty()) return null; return detectTargetModule(survivedModules, project); }