void (String className, String methodName, Pair<String, String>... expectedTests) { PsiClass aClass = myJavaFacade.findClass(className); PsiMethod method = "<init>".equals(methodName) ? assertOneElement(aClass.getConstructors()) : assertOneElement(aClass.findMethodsByName(methodName, false)); Couple<String> methodKey = ShowAffectedTestsAction.getMethodKey(method); TestDiscoveryIndex testDiscoveryIndex = TestDiscoveryIndex.getInstance(myProject); MultiMap<String, String> rawActualTests1 = testDiscoveryIndex.getTestsByMethodName(methodKey.getFirst(), methodKey.getSecond(), JUnitConfiguration.FRAMEWORK_ID); MultiMap<String, String> rawActualTests2 = testDiscoveryIndex.getTestsByClassName(className, JUnitConfiguration.FRAMEWORK_ID); Set<Pair<String, String>> actualTests1 = rawActualTests1.entrySet().stream().flatMap(e -> e.getValue().stream().map(m -> Pair.create(e.getKey(), m))) .collect(Collectors.toSet()); Set<Pair<String, String>> actualTests2 = rawActualTests2.entrySet().stream().flatMap(e -> e.getValue().stream().map(m -> Pair.create(e.getKey(), m))) .collect(Collectors.toSet()); assertEquals(ContainerUtil.newHashSet(expectedTests), actualTests1); assertEquals(ContainerUtil.newHashSet(expectedTests), actualTests2); Set<String> modules = actualTests1 .stream() .flatMap( test -> testDiscoveryIndex.getTestModulesByMethodName(test.getFirst(), test.getSecond(), JUnitConfiguration.FRAMEWORK_ID).stream()) .collect(Collectors.toSet()); String module = assertOneElement(modules); assertEquals(myModule.getName(), module); for (Pair<String, String> test : expectedTests) { assertTrue(testDiscoveryIndex.hasTestTrace(test.getFirst(), test.getSecond(), JUnitConfiguration.FRAMEWORK_ID)); } assertFalse(testDiscoveryIndex.hasTestTrace("dummy test name", "123", JUnitConfiguration.FRAMEWORK_ID)); }