コード例 #1
0
  public void testAllInPackageForProject() throws IOException, ExecutionException {
    // module1 -> module2 -> module3
    // module5
    addModule("module5");
    addDependency(getModule1(), getModule2());
    addDependency(getModule2(), getModule3());
    String[][] outputs = new String[4][];
    for (int i = 0; i < 4; i++) {
      outputs[i] = addOutputs(getModule(i), i + 1);
    }

    PsiPackage defaultPackage = JavaPsiFacade.getInstance(myProject).findPackage("");
    JUnitConfiguration configuration =
        createJUnitConfiguration(
            defaultPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
    configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT);
    JavaParameters javaParameters = checkCanRun(configuration);
    String classPath = javaParameters.getClassPath().getPathsString();
    assertEquals(-1, classPath.indexOf(JarFileSystem.PROTOCOL_PREFIX));
    assertEquals(-1, classPath.indexOf(LocalFileSystem.PROTOCOL_PREFIX));
    for (int i = 0; i < 4; i++) {
      checkContains(classPath, outputs[i][0]);
      checkContains(classPath, outputs[i][1]);
    }
  }
コード例 #2
0
 public void testCantCreateConfiguration() {
   PsiClass objectClass =
       JavaPsiFacade.getInstance(myProject)
           .findClass(CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(myProject));
   assertNull(createConfiguration(objectClass));
   assertNull(createConfiguration(JUnitUtil.getContainingPackage(objectClass)));
 }
コード例 #3
0
 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});
 }