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]);
}
}
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 });
}
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);
}
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());
}
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);
}
Aggregations