void (@NotNull Project project, @NotNull DiscoveredTestsTree tree, @NotNull Ref<? extends JBPopup> ref, @NotNull ConfigurationContext context, @NotNull String title) { Executor executor = DefaultRunExecutor.getRunExecutorInstance(); Module targetModule = TestDiscoveryConfigurationProducer.detectTargetModule(tree.getContainingModules(), project); //first producer with results will be picked List<Location<PsiMethod>> testMethods = Arrays.stream(tree.getTestMethods()) .map(TestMethodUsage::calculateLocation) .filter(Objects::nonNull) .toList(); getRunConfigurationProducers(project).stream() .map(producer -> pair(producer, ContainerUtil.filter(testMethods, producer::isApplicable))) .max(Comparator.comparingInt(p -> p.second.size())) .map(p -> { @SuppressWarnings("unchecked") Location<PsiMethod>[] locations = p.second.toArray(new Location[0]); return p.first.createProfile(locations, targetModule, context, title); }) .ifPresent(profile -> { try { ExecutionEnvironmentBuilder.create(project, executor, profile).buildAndExecute(); } catch (ExecutionException e) { ExecutionUtil.handleExecutionError(project, executor.getToolWindowId(), title, e); } JBPopup popup = ref.get(); if (popup != null) { popup.cancel(); } }); }