Search in sources :

Example 16 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.

the class ConfigurationsTest method testAllInPackageForProject.

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]);
    }
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext)

Example 17 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.

the class ConfigurationsTest method testAllInPackageForCommonAncestorModule.

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 });
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) Module(com.intellij.openapi.module.Module)

Example 18 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.

the class ConfigurationsTest method testTestClassPathWhenRunningConfigurations.

public void testTestClassPathWhenRunningConfigurations() throws IOException, ExecutionException {
    addModule("module4", false);
    Module module4 = getModule4();
    assignJdk(module4);
    addSourcePath(module4, "testSrc", true);
    addSourcePath(module4, "src", false);
    String output = setCompilerOutput(module4, "classes", false);
    String testOuput = setCompilerOutput(module4, "testClasses", true);
    ApplicationConfiguration applicationConfiguration = createConfiguration(findClass(module4, "Application"));
    JavaParameters parameters = checkCanRun(applicationConfiguration);
    String classPath = parameters.getClassPath().getPathsString();
    checkDoesNotContain(classPath, testOuput);
    checkContains(classPath, output);
    JUnitConfiguration junitConfiguration = createJUnitConfiguration(findClass(module4, "TestApplication"), TestInClassConfigurationProducer.class, new MapDataContext());
    parameters = checkCanRun(junitConfiguration);
    classPath = parameters.getClassPath().getPathsString();
    checkContains(classPath, testOuput);
    checkContains(classPath, output);
    applicationConfiguration.MAIN_CLASS_NAME = junitConfiguration.getPersistentData().getMainClassName();
    classPath = checkCanRun(applicationConfiguration).getClassPath().getPathsString();
    checkContains(classPath, testOuput);
    checkContains(classPath, output);
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) Module(com.intellij.openapi.module.Module) ApplicationConfiguration(com.intellij.execution.application.ApplicationConfiguration)

Example 19 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.

the class ContextConfigurationTest method testJUnitPackage.

public void testJUnitPackage() {
    PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
    PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
    final MapDataContext dataContext = new MapDataContext();
    final Module module = ModuleUtil.findModuleForPsiElement(psiClass);
    dataContext.put(DataConstants.MODULE, module);
    JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, dataContext);
    checkTestObject(JUnitConfiguration.TEST_PACKAGE, configuration);
    checkPackage(PACKAGE_NAME, configuration);
    checkGeneretedName(configuration, PACKAGE_NAME + " in " + module.getName());
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage) Module(com.intellij.openapi.module.Module)

Example 20 with MapDataContext

use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.

the class ContextConfigurationTest method testJUnitClassTest.

public void testJUnitClassTest() {
    PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
    final MapDataContext dataContext = new MapDataContext();
    JUnitConfiguration configuration = createJUnitConfiguration(psiClass, TestInClassConfigurationProducer.class, dataContext);
    checkTestObject(JUnitConfiguration.TEST_CLASS, configuration);
    checkClassName(CLASS_NAME, configuration);
    checkPackage(PACKAGE_NAME, configuration);
    checkGeneretedName(configuration, SHORT_CLASS_NAME);
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) PsiClass(com.intellij.psi.PsiClass)

Aggregations

MapDataContext (com.intellij.testFramework.MapDataContext)25 PsiClass (com.intellij.psi.PsiClass)8 Module (com.intellij.openapi.module.Module)6 RenameHandler (com.intellij.refactoring.rename.RenameHandler)4 PsiPackage (com.intellij.psi.PsiPackage)3 PsiElementRenameHandler (com.intellij.refactoring.rename.PsiElementRenameHandler)3 NotNull (org.jetbrains.annotations.NotNull)3 JavaFxPropertyRenameHandler (org.jetbrains.plugins.javaFX.refactoring.JavaFxPropertyRenameHandler)3 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 ApplicationConfiguration (com.intellij.execution.application.ApplicationConfiguration)2 TestActionEvent (com.intellij.testFramework.TestActionEvent)2 JavaOverrideMethodsHandler (com.intellij.codeInsight.generation.JavaOverrideMethodsHandler)1 PsiLocation (com.intellij.execution.PsiLocation)1 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 JUnitConfiguration (com.intellij.execution.junit.JUnitConfiguration)1 PsiElement2UsageTargetAdapter (com.intellij.find.findUsages.PsiElement2UsageTargetAdapter)1 DataProvider (com.intellij.openapi.actionSystem.DataProvider)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1