void (@NotNull Class<? extends TestIndexingModeSupporter> aClass, @NotNull TestIndexingModeSupporter.IndexingModeTestHandler handler, @NotNull TestSuite parentSuite) { if (handler.shouldIgnore(aClass)) return; try { TestSuite suite = handler.createTestSuite(); suite.setName(aClass.getSimpleName()); boolean foundTests = false; Constructor<? extends TestIndexingModeSupporter> constructor = aClass.getConstructor(); for (Method declaredMethod : MethodSorter.getDeclaredMethods(aClass)) { if (!Modifier.isPublic(declaredMethod.getModifiers())) continue; String methodName = declaredMethod.getName(); if (!methodName.startsWith("test")) continue; if (TestFrameworkUtil.isPerformanceTest(methodName, aClass.getName())) continue; if (handler.shouldIgnore(declaredMethod)) continue; TestIndexingModeSupporter aCase = constructor.newInstance(); aCase.setIndexingMode(handler.getIndexingMode()); if (aCase instanceof TestCase testCase) { testCase.setName(methodName); if (UsefulTestCase.IS_UNDER_TEAMCITY) { Test wrapper = IndexingModeTestHandler.wrapForTeamCity(testCase, handler.getIndexingMode()); suite.addTest(wrapper); } else { suite.addTest(testCase); } } else { parentSuite.addTest(warning(aClass.getName() + "is not a TestSuite")); } foundTests = true; } if (foundTests) { parentSuite.addTest(suite); } } catch (NoSuchMethodException e) { parentSuite.addTest(warning("Failed to find default constructor for " + aClass.getName() + ", see log")); //noinspection CallToPrintStackTrace e.printStackTrace(); } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { parentSuite.addTest(warning("Failed to instantiate " + aClass.getName() + ", see log")); //noinspection CallToPrintStackTrace e.printStackTrace(); } }