use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.
the class ConfigurationRefactoringsTest method testRenameJUnitPackage.
public void testRenameJUnitPackage() throws IOException {
PsiPackage psiPackage = mySource.createPackage("pkg");
JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
rename(psiPackage, "pkg2");
checkPackage("pkg2", configuration);
PsiPackage outer = mySource.createPackage("outerPkg");
move(JavaPsiFacade.getInstance(myProject).findPackage("pkg2"), outer.getQualifiedName());
checkPackage("outerPkg.pkg2", configuration);
rename(outer, "outer2");
checkPackage("outer2.pkg2", configuration);
}
use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.
the class ContextConfigurationTest method testMethodInAbstractJUnit3TestCase.
public void testMethodInAbstractJUnit3TestCase() throws Exception {
String packageName = "abstractTests";
String shortName = "AbstractTestImpl1";
String qualifiedName = StringUtil.getQualifiedName(packageName, shortName);
PsiClass psiClass = findClass(getModule1(), qualifiedName);
PsiMethod testMethod = psiClass.findMethodsByName(METHOD_NAME, true)[0];
MapDataContext dataContext = new MapDataContext();
dataContext.put(CommonDataKeys.PROJECT, myProject);
if (LangDataKeys.MODULE.getData(dataContext) == null) {
dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(testMethod));
}
dataContext.put(Location.DATA_KEY, MethodLocation.elementInClass(testMethod, psiClass));
ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
RunnerAndConfigurationSettings settings = context.getConfiguration();
JUnitConfiguration configuration = (JUnitConfiguration) settings.getConfiguration();
checkClassName(qualifiedName, configuration);
checkMethodName(METHOD_NAME, configuration);
checkPackage(packageName, configuration);
checkGeneretedName(configuration, shortName + "." + METHOD_NAME);
}
use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.
the class ContextConfigurationTest method testJUnitDefaultPackage.
public void testJUnitDefaultPackage() {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
PsiPackage defaultPackage = psiPackage.getParentPackage();
final Module module = ModuleUtil.findModuleForPsiElement(psiClass);
final MapDataContext dataContext = new MapDataContext();
dataContext.put(DataConstants.MODULE, module);
JUnitConfiguration configuration = createJUnitConfiguration(defaultPackage, AllInPackageConfigurationProducer.class, dataContext);
checkTestObject(JUnitConfiguration.TEST_PACKAGE, configuration);
checkPackage("", configuration);
checkGeneretedName(configuration, "All in " + module.getName());
}
use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.
the class OverrideImplement15Test method testInAnnotationType.
public void testInAnnotationType() {
String name = getTestName(false);
configureByFile(BASE_DIR + "before" + name + ".java");
int offset = getEditor().getCaretModel().getOffset();
PsiElement context = getFile().findElementAt(offset);
final PsiClass aClass = PsiTreeUtil.getParentOfType(context, PsiClass.class);
assertTrue(aClass != null && aClass.isAnnotationType());
final JavaOverrideMethodsHandler handler = new JavaOverrideMethodsHandler();
assertTrue(handler.isValidFor(getEditor(), getFile()));
assertFalse(handler.isAvailableForQuickList(getEditor(), getFile(), new MapDataContext()));
}
use of com.intellij.testFramework.MapDataContext in project intellij-community by JetBrains.
the class ConfigurationsTest method testCreateConfiguration.
public void testCreateConfiguration() throws IOException, ExecutionException {
Module module1 = getModule1();
PsiClass psiClass = findTestA(module1);
JUnitConfiguration configuration = createConfiguration(psiClass);
assertEquals(Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules()));
checkClassName(psiClass.getQualifiedName(), configuration);
assertEquals(psiClass.getName(), configuration.getName());
checkTestObject(JUnitConfiguration.TEST_CLASS, configuration);
Module module2 = getModule2();
Assertion.compareUnordered(new Module[] { module1, module2 }, configuration.getValidModules());
PsiClass innerTest = findClass(module1, INNER_TEST_NAME);
configuration = createJUnitConfiguration(innerTest, TestInClassConfigurationProducer.class, new MapDataContext());
checkClassName(RT_INNER_TEST_NAME, configuration);
checkCanRun(configuration);
PsiMethod[] testMethod = innerTest.findMethodsByName("test", false);
assertEquals(1, testMethod.length);
configuration = createConfiguration(testMethod[0]);
checkClassName(RT_INNER_TEST_NAME, configuration);
checkMethodName("test", configuration);
checkTestObject(JUnitConfiguration.TEST_METHOD, configuration);
checkCanRun(configuration);
PsiMethod mainMethod = innerTest.findMethodsByName("main", false)[0];
ApplicationConfiguration appConfiguration = createConfiguration(mainMethod);
assertEquals(RT_INNER_TEST_NAME, appConfiguration.MAIN_CLASS_NAME);
checkCanRun(configuration);
}
Aggregations