use of com.theoryinpractice.testng.model.TestData in project intellij-community by JetBrains.
the class TestNGTestDiscoveryRunnableState method createSearchingForTestsTask.
@Override
public SearchingForTestsTask createSearchingForTestsTask() {
return new SearchingForTestsTask(myServerSocket, getConfiguration(), myTempFile) {
@Override
protected void search() throws CantRunException {
myClasses.clear();
final TestData data = getConfiguration().getPersistantData();
final Pair<String, String> position = data.TEST_OBJECT.equals(TestType.SOURCE.getType()) ? Pair.create(data.getMainClassName(), data.getMethodName()) : null;
final Set<String> patterns = TestDiscoverySearchHelper.search(getProject(), position, data.getChangeList(), getConfiguration().getFrameworkPrefix());
final Module module = getConfiguration().getConfigurationModule().getModule();
final GlobalSearchScope searchScope = module != null ? GlobalSearchScope.moduleWithDependenciesScope(module) : GlobalSearchScope.projectScope(getProject());
TestNGTestPattern.fillTestObjects(myClasses, patterns, TestSearchScope.MODULE_WITH_DEPENDENCIES, getConfiguration(), searchScope);
}
@Override
protected void onFound() {
super.onFound();
writeClassesPerModule(myClasses);
}
};
}
use of com.theoryinpractice.testng.model.TestData 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.TestData 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.TestData in project intellij-community by JetBrains.
the class AbstractTestNGPatternConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
final LinkedHashSet<String> classes = new LinkedHashSet<>();
final PsiElement element = checkPatterns(context, classes);
if (element == null) {
return false;
}
sourceElement.set(element);
final TestData data = configuration.getPersistantData();
data.setPatterns(classes);
data.TEST_OBJECT = TestType.PATTERN.getType();
data.setScope(setupPackageConfiguration(context, configuration, data.getScope()));
configuration.setGeneratedName();
setupConfigurationParamName(configuration, context.getLocation());
return true;
}
use of com.theoryinpractice.testng.model.TestData in project intellij-community by JetBrains.
the class AbstractTestNGPackageConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
final PsiElement element = context.getPsiLocation();
PsiPackage aPackage = JavaRuntimeConfigurationProducerBase.checkPackage(element);
if (aPackage == null) {
return false;
}
final Location location = context.getLocation();
if (location == null) {
return false;
}
if (!LocationUtil.isJarAttached(location, aPackage, TestNGUtil.TEST_ANNOTATION_FQN)) {
return false;
}
final TestData data = configuration.data;
data.PACKAGE_NAME = aPackage.getQualifiedName();
data.TEST_OBJECT = TestType.PACKAGE.getType();
data.setScope(setupPackageConfiguration(context, configuration, data.getScope()));
configuration.setGeneratedName();
sourceElement.set(aPackage);
return true;
}
Aggregations