private JUnitConfiguration createConfiguration(PsiPackage psiPackage, Module module) { JUnitConfiguration configuration = new JUnitConfiguration( "", myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]); configuration.getPersistentData().TEST_OBJECT = JUnitConfiguration.TEST_PACKAGE; configuration.getPersistentData().PACKAGE_NAME = psiPackage.getQualifiedName(); configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT); configuration.setModule(module); return configuration; }
private static List<String> extractAllInPackageTests( JavaParameters parameters, PsiPackage psiPackage) throws IOException { String filePath = ContainerUtil.find( parameters.getProgramParametersList().getArray(), value -> StringUtil.startsWithChar(value, '@') && !StringUtil.startsWith(value, "@w@")) .substring(1); List<String> lines = readLinesFrom(new File(filePath)); assertEquals(psiPackage.getQualifiedName(), lines.get(0)); // lines.remove(0); lines.remove(0); return lines; }
public void testAllInPackageForCommonAncestorModule() throws IOException, ExecutionException { disposeModule(getModule2()); addModule("module5", true); Module ancestor = getModule1(); Module child1 = getModule2(); Module child2 = getModule3(); addDependency(ancestor, child1); addDependency(ancestor, child2); PsiPackage psiPackage = JavaPsiFacade.getInstance(myProject).findPackage("test1"); JUnitConfiguration configuration = createJUnitConfiguration( psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext()); configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT); assertNotNull(configuration); checkPackage(psiPackage.getQualifiedName(), configuration); assertEmpty(configuration.getModules()); JavaParameters parameters = checkCanRun(configuration); List<String> tests = extractAllInPackageTests(parameters, psiPackage); String childTest1 = findClass(child1, "test1.TestB").getQualifiedName(); String childTest2 = findClass(child2, "test1.Test5").getQualifiedName(); String ancestorTest = findClass(ancestor, "test1.TestA").getQualifiedName(); CHECK.containsAll(tests, new Object[] {ancestorTest, childTest1, childTest2}); }