Search in sources :

Example 6 with TestData

use of com.theoryinpractice.testng.model.TestData in project intellij-community by JetBrains.

the class TestNGRunnableState method createJavaParameters.

@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
    final JavaParameters javaParameters = super.createJavaParameters();
    javaParameters.setMainClass("org.testng.RemoteTestNGStarter");
    try {
        port = NetUtils.findAvailableSocketPort();
    } catch (IOException e) {
        throw new ExecutionException("Unable to bind to port " + port, e);
    }
    final TestData data = getConfiguration().getPersistantData();
    if (data.getOutputDirectory() != null && !data.getOutputDirectory().isEmpty()) {
        javaParameters.getProgramParametersList().add(CommandLineArgs.OUTPUT_DIRECTORY, data.getOutputDirectory());
    }
    javaParameters.getProgramParametersList().add(CommandLineArgs.USE_DEFAULT_LISTENERS, String.valueOf(data.USE_DEFAULT_REPORTERS));
    @NonNls final StringBuilder buf = new StringBuilder();
    if (data.TEST_LISTENERS != null && !data.TEST_LISTENERS.isEmpty()) {
        buf.append(StringUtil.join(data.TEST_LISTENERS, ";"));
    }
    collectListeners(javaParameters, buf, IDEATestNGListener.EP_NAME, ";");
    if (buf.length() > 0)
        javaParameters.getProgramParametersList().add(CommandLineArgs.LISTENER, buf.toString());
    createServerSocket(javaParameters);
    createTempFiles(javaParameters);
    return javaParameters;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) TestData(com.theoryinpractice.testng.model.TestData) JavaParameters(com.intellij.execution.configurations.JavaParameters) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException)

Example 7 with TestData

use of com.theoryinpractice.testng.model.TestData 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());
}
Also used : TestData(com.theoryinpractice.testng.model.TestData) TestNGTestObject(com.theoryinpractice.testng.model.TestNGTestObject) PsiClass(com.intellij.psi.PsiClass) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with TestData

use of com.theoryinpractice.testng.model.TestData 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());
    }
}
Also used : TestData(com.theoryinpractice.testng.model.TestData) TestNGTestObject(com.theoryinpractice.testng.model.TestNGTestObject) PsiClass(com.intellij.psi.PsiClass) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

TestData (com.theoryinpractice.testng.model.TestData)8 TestNGTestObject (com.theoryinpractice.testng.model.TestNGTestObject)4 PsiClass (com.intellij.psi.PsiClass)3 PsiElement (com.intellij.psi.PsiElement)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 Module (com.intellij.openapi.module.Module)2 ExecutionException (com.intellij.execution.ExecutionException)1 Location (com.intellij.execution.Location)1 JavaParameters (com.intellij.execution.configurations.JavaParameters)1 PsiMethod (com.intellij.psi.PsiMethod)1 PsiPackage (com.intellij.psi.PsiPackage)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 SearchingForTestsTask (com.theoryinpractice.testng.configuration.SearchingForTestsTask)1 IOException (java.io.IOException)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 NonNls (org.jetbrains.annotations.NonNls)1