use of com.theoryinpractice.testng.model.TestNGTestObject in project intellij-community by JetBrains.
the class TestNGConfigurationType method isConfigurationByLocation.
public boolean isConfigurationByLocation(RunConfiguration runConfiguration, Location location) {
TestNGConfiguration config = (TestNGConfiguration) runConfiguration;
TestData testobject = config.getPersistantData();
if (testobject == null)
return false;
else {
final PsiElement element = location.getPsiElement();
final TestNGTestObject testNGTestObject = TestNGTestObject.fromConfig(config);
if (testNGTestObject != null && testNGTestObject.isConfiguredByElement(element)) {
final Module configurationModule = config.getConfigurationModule().getModule();
if (Comparing.equal(location.getModule(), configurationModule))
return true;
final Module predefinedModule = ((TestNGConfiguration) RunManagerEx.getInstanceEx(location.getProject()).getConfigurationTemplate(myFactory).getConfiguration()).getConfigurationModule().getModule();
return Comparing.equal(predefinedModule, configurationModule);
} else {
return false;
}
}
}
use of com.theoryinpractice.testng.model.TestNGTestObject in project intellij-community by JetBrains.
the class DetectClassesToRunTest method doTestMethodConfiguration.
private void doTestMethodConfiguration(PsiClass aClass, PsiClass secondaryClass, PsiMethod configMethod, PsiMethod... expectedMethods) throws CantRunException {
final TestNGConfiguration configuration = new TestNGConfiguration("testOne", getProject(), TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
final TestData data = configuration.getPersistantData();
data.TEST_OBJECT = TestType.METHOD.getType();
data.METHOD_NAME = "testOne";
data.setScope(TestSearchScope.SINGLE_MODULE);
configuration.setModule(data.setMainClass(aClass));
final TestNGTestObject testObject = TestNGTestObject.fromConfig(configuration);
assertNotNull(testObject);
final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<>();
testObject.fillTestObjects(classes);
assertContainsElements(classes.keySet(), aClass);
final Map<PsiMethod, List<String>> methods = classes.get(aClass);
assertContainsElements(methods.keySet(), expectedMethods);
if (secondaryClass != null) {
final Map<PsiMethod, List<String>> configMethods = classes.get(secondaryClass);
assertTrue(configMethods != null);
assertTrue(configMethods.containsKey(configMethod));
}
}
use of com.theoryinpractice.testng.model.TestNGTestObject in project intellij-community by JetBrains.
the class TestNGConfiguration method checkConfiguration.
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
final TestNGTestObject testObject = TestNGTestObject.fromConfig(this);
if (testObject != null) {
testObject.checkConfiguration();
}
JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), getConfigurationModule().getModule());
JavaParametersUtil.checkAlternativeJRE(this);
//TODO add various checks here
}
use of com.theoryinpractice.testng.model.TestNGTestObject in project intellij-community by JetBrains.
the class DetectClassesToRunTest method doTestClassConfiguration.
private void doTestClassConfiguration(PsiClass aClass) throws CantRunException {
final TestNGConfiguration configuration = new TestNGConfiguration("TestA", getProject(), TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
final TestData data = configuration.getPersistantData();
data.TEST_OBJECT = TestType.CLASS.getType();
data.setScope(TestSearchScope.SINGLE_MODULE);
configuration.setModule(data.setMainClass(aClass));
final TestNGTestObject testObject = TestNGTestObject.fromConfig(configuration);
assertNotNull(testObject);
final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<>();
testObject.fillTestObjects(classes);
assertContainsElements(classes.keySet(), aClass);
assertEquals(1, classes.size());
}
use of com.theoryinpractice.testng.model.TestNGTestObject in project intellij-community by JetBrains.
the class DetectClassesToRunTest method doTestPackageConfiguration.
private void doTestPackageConfiguration(PsiClass... containingClasses) throws CantRunException {
final TestNGConfiguration configuration = new TestNGConfiguration("p", getProject(), TestNGConfigurationType.getInstance().getConfigurationFactories()[0]);
final TestData data = configuration.getPersistantData();
data.TEST_OBJECT = TestType.PACKAGE.getType();
data.PACKAGE_NAME = "p";
data.setScope(TestSearchScope.WHOLE_PROJECT);
final TestNGTestObject testObject = TestNGTestObject.fromConfig(configuration);
assertNotNull(testObject);
final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<>();
testObject.fillTestObjects(classes);
assertContainsElements(classes.keySet(), containingClasses);
for (PsiClass psiClass : containingClasses) {
assertEmpty(classes.get(psiClass).keySet());
}
}
Aggregations