use of com.intellij.execution.configurations.JavaParameters 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;
}
use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.
the class TestMethods method createJavaParameters.
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters javaParameters = super.createDefaultJavaParameters();
final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
final RunConfigurationModule configurationModule = getConfiguration().getConfigurationModule();
final Project project = configurationModule.getProject();
final Module module = configurationModule.getModule();
final GlobalSearchScope searchScope = module != null ? module.getModuleRuntimeScope(true) : GlobalSearchScope.allScope(project);
addClassesListToJavaParameters(myFailedTests, testInfo -> testInfo != null ? getTestPresentation(testInfo, project, searchScope) : null, data.getPackageName(), true, javaParameters);
return javaParameters;
}
use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.
the class TestObject method createJavaParameters.
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
JavaParameters javaParameters = super.createJavaParameters();
javaParameters.setMainClass(JUnitConfiguration.JUNIT_START_CLASS);
javaParameters.getProgramParametersList().add(JUnitStarter.IDE_VERSION + JUnitStarter.VERSION);
final StringBuilder buf = new StringBuilder();
collectListeners(javaParameters, buf, IDEAJUnitListener.EP_NAME, "\n");
if (buf.length() > 0) {
try {
myListenersFile = FileUtil.createTempFile("junit_listeners_", "", true);
javaParameters.getProgramParametersList().add("@@" + myListenersFile.getPath());
FileUtil.writeToFile(myListenersFile, buf.toString().getBytes(CharsetToolkit.UTF8_CHARSET));
} catch (IOException e) {
LOG.error(e);
}
}
final Project project = getConfiguration().getProject();
final SourceScope sourceScope = getSourceScope();
if (isJUnit5(getConfiguration().getConfigurationModule().getModule(), sourceScope, project)) {
javaParameters.getProgramParametersList().add(JUnitStarter.JUNIT5_PARAMETER);
javaParameters.getClassPath().add(PathUtil.getJarPathForClass(JUnit5IdeaTestRunner.class));
final PathsList classPath = javaParameters.getClassPath();
classPath.add(PathUtil.getJarPathForClass(TestExecutionListener.class));
classPath.add(PathUtil.getJarPathForClass(JupiterTestEngine.class));
classPath.add(PathUtil.getJarPathForClass(JUnitException.class));
classPath.add(PathUtil.getJarPathForClass(TestEngine.class));
classPath.add(PathUtil.getJarPathForClass(JUnitPlatform.class));
try {
JUnitUtil.getTestCaseClass(sourceScope);
classPath.add(PathUtil.getJarPathForClass(VintageTestEngine.class));
} catch (JUnitUtil.NoJUnitException ignore) {
}
}
return javaParameters;
}
use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.
the class TestObject method addClassesListToJavaParameters.
protected <T> void addClassesListToJavaParameters(Collection<? extends T> elements, Function<T, String> nameFunction, String packageName, boolean createTempFile, JavaParameters javaParameters) throws CantRunException {
try {
if (createTempFile) {
createTempFiles(javaParameters);
}
final Map<Module, List<String>> perModule = forkPerModule() ? new TreeMap<>((o1, o2) -> StringUtil.compare(o1.getName(), o2.getName(), true)) : null;
final List<String> testNames = new ArrayList<>();
for (final T element : elements) {
final String name = nameFunction.fun(element);
if (name == null) {
continue;
}
final PsiElement psiElement = retrievePsiElement(element);
if (perModule != null && psiElement != null) {
final Module module = ModuleUtilCore.findModuleForPsiElement(psiElement);
if (module != null) {
List<String> list = perModule.get(module);
if (list == null) {
list = new ArrayList<>();
perModule.put(module, list);
}
list.add(name);
}
} else {
testNames.add(name);
}
}
final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
if (perModule != null) {
for (List<String> perModuleClasses : perModule.values()) {
Collections.sort(perModuleClasses);
testNames.addAll(perModuleClasses);
}
} else if (JUnitConfiguration.TEST_PACKAGE.equals(data.TEST_OBJECT)) {
//sort tests in FQN order
Collections.sort(testNames);
}
final String category = JUnitConfiguration.TEST_CATEGORY.equals(data.TEST_OBJECT) ? data.getCategory() : "";
JUnitStarter.printClassesList(testNames, packageName, category, myTempFile);
writeClassesPerModule(packageName, javaParameters, perModule);
} catch (IOException e) {
LOG.error(e);
}
}
use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.
the class MavenJUnitPatcherTest method testArgList.
public void testArgList() throws Exception {
VirtualFile m1 = createModulePom("m1", "<groupId>test</groupId>" + "<artifactId>m1</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>test</groupId>" + " <artifactId>m2</artifactId>" + " <version>1</version>" + " </dependency>" + "</dependencies>" + "<build><plugins>" + " <plugin>" + " <groupId>org.apache.maven.plugins</groupId>" + " <artifactId>maven-surefire-plugin</artifactId>" + " <version>2.16</version>" + " <configuration>" + " <argLine>-Xmx2048M -XX:MaxPermSize=512M \"-Dargs=can have spaces\"</argLine>" + " </configuration>" + " </plugin>" + "</plugins></build>");
importProjects(m1);
Module module = getModule("m1");
MavenJUnitPatcher mavenJUnitPatcher = new MavenJUnitPatcher();
JavaParameters javaParameters = new JavaParameters();
mavenJUnitPatcher.patchJavaParameters(module, javaParameters);
assertEquals(asList("-Xmx2048M", "-XX:MaxPermSize=512M", "-Dargs=can have spaces"), javaParameters.getVMParametersList().getList());
}
Aggregations