use of com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl in project intellij-community by JetBrains.
the class JUnit4IntegrationTest method ignoredTestMethod.
@Test
public void ignoredTestMethod() throws Throwable {
EdtTestUtil.runInEdtAndWait(() -> {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
assertNotNull(psiClass);
PsiMethod testMethod = psiClass.findMethodsByName(METHOD_NAME, false)[0];
JUnitConfiguration configuration = createConfiguration(testMethod);
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(RunManagerImpl.getInstanceImpl(getProject()), configuration, false);
ExecutionEnvironment environment = new ExecutionEnvironment(executor, ProgramRunnerUtil.getRunner(DefaultRunExecutor.EXECUTOR_ID, settings), settings, getProject());
TestObject state = configuration.getState(executor, environment);
JavaParameters parameters = state.getJavaParameters();
parameters.setUseDynamicClasspath(getProject());
GeneralCommandLine commandLine = parameters.toCommandLine();
StringBuffer buf = new StringBuffer();
StringBuffer err = new StringBuffer();
OSProcessHandler process = new OSProcessHandler(commandLine);
process.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
String text = event.getText();
try {
if (outputType == ProcessOutputTypes.STDOUT && !text.isEmpty() && ServiceMessage.parse(text.trim()) == null) {
buf.append(text);
}
if (outputType == ProcessOutputTypes.STDERR) {
err.append(text);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
});
process.startNotify();
process.waitFor();
process.destroyProcess();
String testOutput = buf.toString();
assertEmpty(err.toString());
switch(myJUnitVersion) {
//shouldn't work for old versions
case "4.4":
//shouldn't work for old versions
case "4.5":
break;
default:
assertTrue(testOutput, testOutput.contains("Test1"));
}
});
}
use of com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl in project intellij-community by JetBrains.
the class CopyConfigurationAction method doActionPerformed.
@Override
@SuppressWarnings("unchecked")
protected void doActionPerformed(DashboardRunConfigurationNode node) {
RunManagerEx runManager = RunManagerEx.getInstanceEx(node.getProject());
RunnerAndConfigurationSettings settings = node.getConfigurationSettings();
RunnerAndConfigurationSettings copiedSettings = ((RunnerAndConfigurationSettingsImpl) settings).clone();
runManager.setUniqueNameIfNeed(copiedSettings);
copiedSettings.setFolderName(settings.getFolderName());
final ConfigurationFactory factory = settings.getFactory();
if (factory instanceof ConfigurationFactoryEx) {
((ConfigurationFactoryEx) factory).onConfigurationCopied(settings.getConfiguration());
}
if (RunDialog.editConfiguration(node.getProject(), copiedSettings, ExecutionBundle.message("run.dashboard.edit.configuration.dialog.title"))) {
runManager.addConfiguration(copiedSettings, runManager.isConfigurationShared(settings), runManager.getBeforeRunTasks(settings.getConfiguration()), false);
}
}
use of com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl in project intellij-community by JetBrains.
the class CompoundRunConfiguration method getState.
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull final ExecutionEnvironment environment) throws ExecutionException {
try {
checkConfiguration();
} catch (RuntimeConfigurationException e) {
throw new ExecutionException(e.getMessage());
}
return new RunProfileState() {
@Nullable
@Override
public ExecutionResult execute(final Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
ApplicationManager.getApplication().invokeLater(() -> {
RunManagerImpl manager = RunManagerImpl.getInstanceImpl(getProject());
for (RunConfiguration configuration : getSetToRun()) {
RunnerAndConfigurationSettings settings = new RunnerAndConfigurationSettingsImpl(manager, configuration, false);
ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.createOrNull(executor, settings);
if (builder != null) {
ExecutionManager.getInstance(getProject()).restartRunProfile(builder.activeTarget().dataContext(null).build());
}
}
});
return null;
}
};
}
use of com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl in project intellij-community by JetBrains.
the class ConfigurationRefactoringsTest method testRenameBadTestClass.
public void testRenameBadTestClass() throws IOException {
PsiClass psiClass = mySource.createClass("NotATest", NOT_A_TEST);
assertNotNull(psiClass);
JUnitConfigurationType instance = JUnitConfigurationType.getInstance();
assertNotNull(instance);
JUnitConfiguration configuration = new JUnitConfiguration("notATest", myProject, instance.getConfigurationFactories()[0]);
configuration.setMainClass(psiClass);
configuration.setModule(configuration.getValidModules().iterator().next());
checkConfigurationException("NotATest isn't test class", configuration);
RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
rename(psiClass, "NotATest2");
JUnitConfiguration.Data data = configuration.getPersistentData();
assertEquals("NotATest2", data.getMainClassName());
data.METHOD_NAME = "test";
data.TEST_OBJECT = JUnitConfiguration.TEST_METHOD;
checkConfigurationException("Test method 'test' doesn't exist", configuration);
rename(psiClass.findMethodsByName("test", false)[0], "test2");
assertEquals("NotATest2", data.getMainClassName());
assertEquals("test2", data.getMethodName());
}
use of com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl in project intellij-community by JetBrains.
the class ConfigurationRefactoringsTest method createConfiguration.
@Override
protected <T extends RunConfiguration> T createConfiguration(@NotNull PsiElement psiClass, @NotNull MapDataContext dataContext) {
T configuration = super.createConfiguration(psiClass, dataContext);
RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
return configuration;
}
Aggregations