From 5db94b3ddd8985c13d009aebdf1d1e80ea7156d9 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Sun, 21 Jun 2015 15:56:55 +0300 Subject: [PATCH] import tests: global action provided create SMRunnerConsoleProperties by restored configuration read from provided xml allow to import without framework provided, though no navigation, rerun failed etc is possible --- .../JavaTestFrameworkRunnableState.java | 9 +-- .../src/idea/LangActions.xml | 5 ++ .../ImportedTestConsoleProperties.java | 31 +++++--- .../history/ImportedTestRunnableState.java | 23 ++++-- .../SMRunnerConsolePropertiesProvider.java | 26 +++++++ .../sm/runner/SMTRunnerConsoleProperties.java | 19 +++-- .../sm/runner/ui/SMTRunnerConsoleView.java | 3 +- .../sm/runner/ui/SMTestRunnerResultsForm.java | 11 ++- .../runner/ui/actions/ImportTestsAction.java | 70 +++++++++++++++---- .../ui/SMTRunnerUIActionsHandlerTest.java | 7 +- .../SMTRunnerStatisticsPanelTest.java | 4 +- .../testframework/TestConsoleProperties.java | 5 +- .../execution/testframework/TestsUIUtil.java | 8 ++- .../execution/testframework/ToolbarPanel.java | 20 ++++-- .../coverage/actions/TrackCoverageAction.java | 3 +- .../OpenGradleTestResultActionProvider.java | 3 +- plugins/junit/junit.iml | 2 +- .../execution/junit/JUnitConfiguration.java | 10 ++- .../intellij/execution/junit/TestObject.java | 7 -- .../junit2/ui/actions/LvcsLabeler.java | 3 +- .../configuration/TestNGConfiguration.java | 10 ++- .../configuration/TestNGRunnableState.java | 7 -- plugins/testng/testng.iml | 5 +- 23 files changed, 207 insertions(+), 84 deletions(-) create mode 100644 platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMRunnerConsolePropertiesProvider.java diff --git a/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java b/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java index 6afe84a393dd..7ce1975f1858 100644 --- a/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java +++ b/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java @@ -25,11 +25,11 @@ import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.testframework.*; import com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction; import com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil; +import com.intellij.execution.testframework.sm.runner.SMRunnerConsolePropertiesProvider; import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties; import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView; import com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm; import com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView; -import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.util.JavaParametersUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; @@ -57,7 +57,6 @@ import com.intellij.psi.search.GlobalSearchScopesCore; import com.intellij.rt.execution.CommandLineWrapper; import com.intellij.util.PathUtil; import com.intellij.util.ui.UIUtil; -import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTypes; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.model.serialization.PathMacroUtil; @@ -69,7 +68,7 @@ import java.net.InetAddress; import java.net.ServerSocket; import java.util.Locale; -public abstract class JavaTestFrameworkRunnableState & CommonJavaRunConfigurationParameters> extends JavaCommandLineState { +public abstract class JavaTestFrameworkRunnableState & CommonJavaRunConfigurationParameters & SMRunnerConsolePropertiesProvider> extends JavaCommandLineState { private static final Logger LOG = Logger.getInstance("#" + JavaTestFrameworkRunnableState.class.getName()); protected ServerSocket myServerSocket; protected File myTempFile; @@ -92,8 +91,6 @@ public abstract class JavaTestFrameworkRunnableState + + + + diff --git a/platform/smRunner/src/com/intellij/execution/testframework/history/ImportedTestConsoleProperties.java b/platform/smRunner/src/com/intellij/execution/testframework/history/ImportedTestConsoleProperties.java index 27212096546b..5db4bf95e709 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/history/ImportedTestConsoleProperties.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/history/ImportedTestConsoleProperties.java @@ -15,7 +15,10 @@ */ package com.intellij.execution.testframework.history; +import com.intellij.execution.Executor; import com.intellij.execution.Location; +import com.intellij.execution.configurations.RunConfiguration; +import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.filters.Filter; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.testframework.TestConsoleProperties; @@ -34,14 +37,17 @@ import org.jetbrains.annotations.Nullable; import java.io.File; public class ImportedTestConsoleProperties extends SMTRunnerConsoleProperties implements SMCustomMessagesParsing { - private final SMTRunnerConsoleProperties myProperties; + private final @Nullable SMTRunnerConsoleProperties myProperties; private final File myFile; private final ProcessHandler myHandler; - public ImportedTestConsoleProperties(SMTRunnerConsoleProperties properties, + public ImportedTestConsoleProperties(@Nullable SMTRunnerConsoleProperties properties, File file, - ProcessHandler handler) { - super(properties.getConfiguration(), properties.getTestFrameworkName(), properties.getExecutor()); + ProcessHandler handler, + Project project, RunProfile runConfiguration, + String frameworkName, + Executor executor) { + super(project, runConfiguration, frameworkName, executor); myProperties = properties; myFile = file; myHandler = handler; @@ -67,40 +73,43 @@ public class ImportedTestConsoleProperties extends SMTRunnerConsoleProperties im @Override public Navigatable getErrorNavigatable(@NotNull Location location, @NotNull String stacktrace) { - return myProperties.getErrorNavigatable(location, stacktrace); + return myProperties == null ? null : myProperties.getErrorNavigatable(location, stacktrace); } + @Nullable @Override public Navigatable getErrorNavigatable(@NotNull Project project, @NotNull String stacktrace) { - return myProperties.getErrorNavigatable(project, stacktrace); + return myProperties == null ? null : myProperties.getErrorNavigatable(project, stacktrace); } @Override public void addStackTraceFilter(Filter filter) { - myProperties.addStackTraceFilter(filter); + if (myProperties != null) { + myProperties.addStackTraceFilter(filter); + } } @Override public boolean fixEmptySuite() { - return myProperties.fixEmptySuite(); + return myProperties != null && myProperties.fixEmptySuite(); } @Override @Nullable public SMTestLocator getTestLocator() { - return myProperties.getTestLocator(); + return myProperties == null ? null : myProperties.getTestLocator(); } @Override @Nullable public TestProxyFilterProvider getFilterProvider() { - return myProperties.getFilterProvider(); + return myProperties == null ? null : myProperties.getFilterProvider(); } @Override @Nullable public AbstractRerunFailedTestsAction createRerunFailedTestsAction(ConsoleView consoleView) { - return myProperties.createRerunFailedTestsAction(consoleView); + return myProperties == null ? null : myProperties.createRerunFailedTestsAction(consoleView); } } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/history/ImportedTestRunnableState.java b/platform/smRunner/src/com/intellij/execution/testframework/history/ImportedTestRunnableState.java index d311a29f4302..495061449946 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/history/ImportedTestRunnableState.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/history/ImportedTestRunnableState.java @@ -19,6 +19,8 @@ import com.intellij.execution.DefaultExecutionResult; import com.intellij.execution.ExecutionException; import com.intellij.execution.ExecutionResult; import com.intellij.execution.Executor; +import com.intellij.execution.configurations.RunConfiguration; +import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.configurations.RunProfileState; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.runners.ProgramRunner; @@ -26,6 +28,7 @@ import com.intellij.execution.testframework.TestFrameworkRunningModel; import com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction; import com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil; import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties; +import com.intellij.execution.testframework.sm.runner.ui.actions.ImportTestsAction; import com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView; import com.intellij.openapi.util.Getter; import org.jetbrains.annotations.NotNull; @@ -36,11 +39,11 @@ import java.io.File; import java.io.OutputStream; public class ImportedTestRunnableState implements RunProfileState { - private SMTRunnerConsoleProperties myProperties; + private ImportTestsAction.ImportRunProfile myRunProfile; private File myFile; - public ImportedTestRunnableState(SMTRunnerConsoleProperties properties, File file) { - myProperties = properties; + public ImportedTestRunnableState(ImportTestsAction.ImportRunProfile profile, File file) { + myRunProfile = profile; myFile = file; } @@ -48,7 +51,19 @@ public class ImportedTestRunnableState implements RunProfileState { @Override public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException { final MyEmptyProcessHandler handler = new MyEmptyProcessHandler(); - ImportedTestConsoleProperties consoleProperties = new ImportedTestConsoleProperties(myProperties, myFile, handler); + final SMTRunnerConsoleProperties properties = myRunProfile.getProperties(); + RunProfile configuration; + final String frameworkName; + if (properties != null) { + configuration = properties.getConfiguration(); + frameworkName = properties.getTestFrameworkName(); + } + else { + configuration = myRunProfile; + frameworkName = "Import Test Results"; + } + final ImportedTestConsoleProperties consoleProperties = new ImportedTestConsoleProperties(properties, myFile, handler, myRunProfile.getProject(), + configuration, frameworkName, executor); final BaseTestsOutputConsoleView console = SMTestRunnerConnectionUtil.createConsole(consoleProperties.getTestFrameworkName(), consoleProperties); final JComponent component = console.getComponent(); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMRunnerConsolePropertiesProvider.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMRunnerConsolePropertiesProvider.java new file mode 100644 index 000000000000..6b609c23dfb8 --- /dev/null +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMRunnerConsolePropertiesProvider.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.execution.testframework.sm.runner; + +import com.intellij.execution.Executor; + +/** + * If {@link com.intellij.execution.configurations.RunConfiguration} uses SMRunner and implements this interface, + * {@link com.intellij.execution.testframework.sm.runner.ui.actions.ImportTestsAction} would work from Main Menu. + */ +public interface SMRunnerConsolePropertiesProvider { + SMTRunnerConsoleProperties createTestConsoleProperties(Executor executor); +} diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java index 5d9f4f1f89db..368a952938f9 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java @@ -18,6 +18,7 @@ package com.intellij.execution.testframework.sm.runner; import com.intellij.execution.Executor; import com.intellij.execution.Location; import com.intellij.execution.configurations.RunConfiguration; +import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.filters.CompositeFilter; import com.intellij.execution.filters.FileHyperlinkInfo; import com.intellij.execution.filters.Filter; @@ -46,9 +47,11 @@ import org.jetbrains.annotations.Nullable; /** * @author Roman Chernyatchik + * Use {@link SMRunnerConsolePropertiesProvider} so importer {@link ImportTestsAction.ImportRunProfile#ImportRunProfile(VirtualFile, Project)} + * would be able to create properties by read configuration and test navigation, rerun failed tests etc. would work on imported results */ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements SMStacktraceParserEx { - private final RunConfiguration myConfiguration; + private final RunProfile myConfiguration; @NotNull private final String myTestFrameworkName; private final CompositeFilter myCustomFilter; private boolean myIdBasedTestTree = false; @@ -60,10 +63,17 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements * @param executor */ public SMTRunnerConsoleProperties(@NotNull RunConfiguration config, @NotNull String testFrameworkName, @NotNull Executor executor) { - super(getStorage(testFrameworkName), config.getProject(), executor); + this(config.getProject(), config, testFrameworkName, executor); + } + + public SMTRunnerConsoleProperties(@NotNull Project project, + @NotNull RunProfile config, + @NotNull String testFrameworkName, + @NotNull Executor executor) { + super(getStorage(testFrameworkName), project, executor); myConfiguration = config; myTestFrameworkName = testFrameworkName; - myCustomFilter = new CompositeFilter(config.getProject()); + myCustomFilter = new CompositeFilter(project); } /** @deprecated {@use #setPrintTestingStartedTime} (to be removed in IDEA 16) */ @@ -82,7 +92,7 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements } @Override - public RunConfiguration getConfiguration() { + public RunProfile getConfiguration() { return myConfiguration; } @@ -114,6 +124,7 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements return getErrorNavigatable(location.getProject(), stacktrace); } + @Nullable @Override public Navigatable getErrorNavigatable(@NotNull final Project project, final @NotNull String stacktrace) { if (myCustomFilter.isEmpty()) { diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerConsoleView.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerConsoleView.java index 71108d49f06a..c5b11f98b6fb 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerConsoleView.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerConsoleView.java @@ -74,8 +74,7 @@ public class SMTRunnerConsoleView extends BaseTestsOutputConsoleView { @Override protected TestResultsPanel createTestResultsPanel() { // Results View - myResultsViewer = new SMTestRunnerResultsForm(myProperties.getConfiguration(), - getConsole().getComponent(), + myResultsViewer = new SMTestRunnerResultsForm(getConsole().getComponent(), getConsole().createConsoleActions(), myProperties, mySplitterProperty); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java index 952a01c719ce..9d5f5c4b0a61 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java @@ -15,7 +15,6 @@ */ package com.intellij.execution.testframework.sm.runner.ui; -import com.intellij.execution.configurations.RunConfiguration; import com.intellij.execution.testframework.*; import com.intellij.execution.testframework.sm.SMRunnerUtil; import com.intellij.execution.testframework.sm.runner.*; @@ -93,14 +92,12 @@ public class SMTestRunnerResultsForm extends TestResultsPanel private Alarm myUpdateQueue; private Set myRequests = Collections.synchronizedSet(new HashSet()); - public SMTestRunnerResultsForm(final RunConfiguration runConfiguration, - @NotNull final JComponent console, + public SMTestRunnerResultsForm(@NotNull final JComponent console, final TestConsoleProperties consoleProperties) { - this(runConfiguration, console, AnAction.EMPTY_ARRAY, consoleProperties, null); + this(console, AnAction.EMPTY_ARRAY, consoleProperties, null); } - public SMTestRunnerResultsForm(final RunConfiguration runConfiguration, - @NotNull final JComponent console, + public SMTestRunnerResultsForm(@NotNull final JComponent console, AnAction[] consoleActions, final TestConsoleProperties consoleProperties, @Nullable String splitterPropertyName) { @@ -108,7 +105,7 @@ public class SMTestRunnerResultsForm extends TestResultsPanel StringUtil.notNullize(splitterPropertyName, DEFAULT_SM_RUNNER_SPLITTER_PROPERTY), 0.2f); myConsoleProperties = consoleProperties; - myProject = runConfiguration.getProject(); + myProject = consoleProperties.getProject(); //Create tests common suite root //noinspection HardCodedStringLiteral diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/actions/ImportTestsAction.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/actions/ImportTestsAction.java index c13ec45e0d7d..7b2758135c4c 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/actions/ImportTestsAction.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/actions/ImportTestsAction.java @@ -17,14 +17,17 @@ package com.intellij.execution.testframework.sm.runner.ui.actions; import com.intellij.execution.ExecutionException; import com.intellij.execution.Executor; -import com.intellij.execution.RunManager; +import com.intellij.execution.ExecutorRegistry; +import com.intellij.execution.configurations.RunConfiguration; import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.configurations.RunProfileState; +import com.intellij.execution.executors.DefaultRunExecutor; import com.intellij.execution.impl.RunManagerImpl; import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.runners.ExecutionEnvironmentBuilder; import com.intellij.execution.testframework.history.ImportedTestRunnableState; +import com.intellij.execution.testframework.sm.runner.SMRunnerConsolePropertiesProvider; import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties; import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnAction; @@ -42,19 +45,28 @@ import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import org.jdom.Document; import org.jdom.Element; -import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.io.IOException; +/** + * 1. chooses file where test results were saved + * 2. finds the configuration element saved during export + * 3. creates corresponding configuration with {@link SMTRunnerConsoleProperties} if configuration implements {@link SMRunnerConsolePropertiesProvider} + * + * Without console properties no navigation, no rerun failed is possible. + */ public class ImportTestsAction extends AnAction { private static final Logger LOG = Logger.getInstance("#" + ImportTestsAction.class.getName()); - private final SMTRunnerConsoleProperties myProperties; + private SMTRunnerConsoleProperties myProperties; + + public ImportTestsAction() { + super("Import Test Results", "Import tests from file", AllIcons.ToolbarDecorator.Import); + } public ImportTestsAction(SMTRunnerConsoleProperties properties) { - super("Import Tests", "Import tests from file", AllIcons.ToolbarDecorator.Import); + this(); myProperties = properties; } @@ -72,7 +84,16 @@ public class ImportTestsAction extends AnAction { final VirtualFile file = FileChooser.chooseFile(xmlDescriptor, project, null); if (file != null) { try { - ExecutionEnvironmentBuilder.create(project, myProperties.getExecutor(), new ImportRunProfile(file, project)).buildAndExecute(); + final ImportRunProfile profile = new ImportRunProfile(file, project); + SMTRunnerConsoleProperties properties = profile.getProperties(); + if (properties == null) { + properties = myProperties; + LOG.info("Failed to detect test framework in " + file.getPath() + + "; use " + (properties != null ? properties.getTestFrameworkName() + " from toolbar" : "no properties")); + } + final Executor executor = properties != null ? properties.getExecutor() + : ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID); + ExecutionEnvironmentBuilder.create(project, executor, profile).buildAndExecute(); } catch (ExecutionException e1) { Messages.showErrorDialog(project, e1.getMessage(), "Import Failed"); @@ -80,13 +101,16 @@ public class ImportTestsAction extends AnAction { } } - private class ImportRunProfile implements RunProfile { + public static class ImportRunProfile implements RunProfile { private final VirtualFile myFile; + private final Project myProject; private RunnerAndConfigurationSettingsImpl mySettings; private boolean myImported; + private SMTRunnerConsoleProperties myProperties; public ImportRunProfile(VirtualFile file, Project project) { myFile = file; + myProject = project; try { final Document document = JDOMUtil.loadDocument(VfsUtilCore.virtualToIoFile(myFile)); final Element config = document.getRootElement().getChild("config"); @@ -94,9 +118,17 @@ public class ImportTestsAction extends AnAction { mySettings = new RunnerAndConfigurationSettingsImpl(RunManagerImpl.getInstanceImpl(project)); try { mySettings.readExternal(config); + final Executor executor = ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID); + if (executor != null) { + final RunConfiguration configuration = mySettings.getConfiguration(); + if (configuration instanceof SMRunnerConsolePropertiesProvider) { + myProperties = ((SMRunnerConsolePropertiesProvider)configuration).createTestConsoleProperties(executor); + } + } } catch (InvalidDataException e) { - LOG.error(e); + LOG.info(e); + mySettings = null; } } } @@ -109,12 +141,18 @@ public class ImportTestsAction extends AnAction { public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException { if (!myImported) { myImported = true; - return new ImportedTestRunnableState(myProperties, VfsUtilCore.virtualToIoFile(myFile)); + return new ImportedTestRunnableState(this, VfsUtilCore.virtualToIoFile(myFile)); } if (mySettings != null) { - return mySettings.getConfiguration().getState(executor, environment); + try { + return mySettings.getConfiguration().getState(executor, environment); + } + catch (Throwable e) { + LOG.info(e); + throw new ExecutionException("Unable to run the configuration: settings are corrupted"); + } } - throw new ExecutionException("Unable to run the configuration"); + throw new ExecutionException("Unable to run the configuration: failed to detect test framework"); } @Override @@ -125,7 +163,15 @@ public class ImportTestsAction extends AnAction { @Nullable @Override public Icon getIcon() { - return myProperties.getConfiguration().getIcon(); + return myProperties != null ? myProperties.getConfiguration().getIcon() : null; + } + + public SMTRunnerConsoleProperties getProperties() { + return myProperties; + } + + public Project getProject() { + return myProject; } } } diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java index a40a0f645096..4efae25104b6 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java @@ -15,7 +15,6 @@ */ package com.intellij.execution.testframework.sm.runner.ui; -import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.testframework.AbstractTestProxy; import com.intellij.execution.testframework.TestConsoleProperties; import com.intellij.execution.testframework.sm.runner.BaseSMTRunnerTestCase; @@ -56,10 +55,8 @@ public class SMTRunnerUIActionsHandlerTest extends BaseSMTRunnerTestCase { TestConsoleProperties.SELECT_FIRST_DEFECT.set(myProperties, false); TestConsoleProperties.TRACK_RUNNING_TEST.set(myProperties, false); - myResultsForm = new SMTestRunnerResultsForm(myProperties.getConfiguration(), - new JLabel(), - myProperties - ) { + myResultsForm = new SMTestRunnerResultsForm(new JLabel(), + myProperties) { @Override public void selectAndNotify(AbstractTestProxy testProxy) { super.selectAndNotify(testProxy); diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsPanelTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsPanelTest.java index 5f176ed9c10f..2fc3e918fe3b 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsPanelTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsPanelTest.java @@ -48,8 +48,8 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase { final TestConsoleProperties consoleProperties = createConsoleProperties(); final ExecutionEnvironment environment = new ExecutionEnvironment(); - myResultsForm = new SMTestRunnerResultsForm(consoleProperties.getConfiguration(), - new JLabel(), + myResultsForm = new SMTestRunnerResultsForm( + new JLabel(), consoleProperties ); Disposer.register(myResultsForm, consoleProperties); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java b/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java index 0ccfa346c6b2..6ebe1b244301 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java @@ -19,6 +19,7 @@ import com.intellij.execution.ExecutionBundle; import com.intellij.execution.Executor; import com.intellij.execution.configurations.ModuleRunProfile; import com.intellij.execution.configurations.RunConfiguration; +import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.executors.DefaultDebugExecutor; import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ExecutionConsole; @@ -93,7 +94,7 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp @NotNull protected GlobalSearchScope initScope() { - RunConfiguration configuration = getConfiguration(); + RunProfile configuration = getConfiguration(); if (!(configuration instanceof ModuleRunProfile)) { return GlobalSearchScope.allScope(myProject); } @@ -163,7 +164,7 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp myListeners.clear(); } - public abstract RunConfiguration getConfiguration(); + public abstract RunProfile getConfiguration(); /** * Allows to make console editable and disable/enable input sending in process stdin stream. diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java index 667f34ae126c..6311dc769ed7 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java @@ -18,6 +18,7 @@ package com.intellij.execution.testframework; import com.intellij.execution.ExecutionBundle; import com.intellij.execution.Location; import com.intellij.execution.configurations.RunConfiguration; +import com.intellij.execution.configurations.RunProfile; import com.intellij.notification.NotificationGroup; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; @@ -68,7 +69,12 @@ public class TestsUIUtil { } } if (Location.DATA_KEY.is(dataId)) return testProxy.getLocation(project, properties.getScope()); - if (RunConfiguration.DATA_KEY.is(dataId)) return properties.getConfiguration(); + if (RunConfiguration.DATA_KEY.is(dataId)) { + final RunProfile configuration = properties.getConfiguration(); + if (configuration instanceof RunConfiguration) { + return configuration; + } + } return null; } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java b/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java index 2662a86efa27..d0f1dc44d6b4 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ToolbarPanel.java @@ -21,6 +21,8 @@ package com.intellij.execution.testframework; import com.intellij.execution.ExecutionBundle; +import com.intellij.execution.configurations.RunConfiguration; +import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.testframework.actions.ScrollToTestSourceAction; import com.intellij.execution.testframework.actions.ShowStatisticsAction; @@ -41,6 +43,7 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.registry.Registry; import com.intellij.util.config.ToggleBooleanProperty; import com.intellij.util.config.ToggleInvertedBooleanProperty; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -50,7 +53,7 @@ public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposab protected final TestTreeExpander myTreeExpander = new TestTreeExpander(); protected final FailedTestsNavigator myOccurenceNavigator; protected final ScrollToTestSourceAction myScrollToSource; - private final ExportTestResultsAction myExportAction; + private @Nullable ExportTestResultsAction myExportAction; private final ArrayList myActions = new ArrayList(); @@ -115,8 +118,11 @@ public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposab actionGroup.add(toggleModelAction); } - myExportAction = ExportTestResultsAction.create(properties.getExecutor().getToolWindowId(), properties.getConfiguration()); - actionGroup.addAction(myExportAction); + final RunProfile configuration = properties.getConfiguration(); + if (configuration instanceof RunConfiguration) { + myExportAction = ExportTestResultsAction.create(properties.getExecutor().getToolWindowId(), (RunConfiguration)configuration); + actionGroup.addAction(myExportAction); + } final AnAction importAction = properties.createImportAction(); if (importAction != null) { @@ -162,7 +168,9 @@ public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposab myScrollToSource.setModel(model); myTreeExpander.setModel(model); myOccurenceNavigator.setModel(model); - myExportAction.setModel(model); + if (myExportAction != null) { + myExportAction.setModel(model); + } for (ToggleModelAction action : myActions) { action.setModel(model); } @@ -212,6 +220,8 @@ public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposab public void dispose() { myScrollToSource.setModel(null); - myExportAction.setModel(null); + if (myExportAction != null) { + myExportAction.setModel(null); + } } } diff --git a/plugins/coverage-common/src/com/intellij/coverage/actions/TrackCoverageAction.java b/plugins/coverage-common/src/com/intellij/coverage/actions/TrackCoverageAction.java index e8ea5e1211dd..e6f8fe849a29 100644 --- a/plugins/coverage-common/src/com/intellij/coverage/actions/TrackCoverageAction.java +++ b/plugins/coverage-common/src/com/intellij/coverage/actions/TrackCoverageAction.java @@ -11,6 +11,7 @@ import com.intellij.execution.Executor; import com.intellij.execution.Location; import com.intellij.execution.configurations.ModuleBasedConfiguration; import com.intellij.execution.configurations.RunConfiguration; +import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration; import com.intellij.execution.testframework.AbstractTestProxy; import com.intellij.execution.testframework.TestConsoleProperties; @@ -98,7 +99,7 @@ public class TrackCoverageAction extends ToggleModelAction { return null; } - final RunConfiguration runConf = myModel.getProperties().getConfiguration(); + final RunProfile runConf = myModel.getProperties().getConfiguration(); if (runConf instanceof ModuleBasedConfiguration) { // if coverage supported for run configuration diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/OpenGradleTestResultActionProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/OpenGradleTestResultActionProvider.java index 522c6057b9eb..b6d3b77bb142 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/OpenGradleTestResultActionProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/OpenGradleTestResultActionProvider.java @@ -16,6 +16,7 @@ package org.jetbrains.plugins.gradle.execution.test.runner; import com.intellij.execution.configurations.RunConfiguration; +import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.testframework.TestConsoleProperties; import com.intellij.execution.testframework.TestFrameworkRunningModel; import com.intellij.execution.testframework.ToggleModelAction; @@ -57,7 +58,7 @@ public class OpenGradleTestResultActionProvider implements ToggleModelActionProv @Override public void setModel(TestFrameworkRunningModel model) { - final RunConfiguration runConfiguration = model.getProperties().getConfiguration(); + final RunProfile runConfiguration = model.getProperties().getConfiguration(); if(runConfiguration instanceof ExternalSystemRunConfiguration) { mySystemId = ((ExternalSystemRunConfiguration)runConfiguration).getSettings().getExternalSystemId(); } diff --git a/plugins/junit/junit.iml b/plugins/junit/junit.iml index f9f01c0b78a1..4b114db22d86 100644 --- a/plugins/junit/junit.iml +++ b/plugins/junit/junit.iml @@ -19,7 +19,7 @@ - + diff --git a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java index 785419e34bdb..6d478e5dda47 100644 --- a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java +++ b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java @@ -24,9 +24,12 @@ import com.intellij.execution.configurations.*; import com.intellij.execution.executors.DefaultRunExecutor; import com.intellij.execution.junit2.configuration.JUnitConfigurable; import com.intellij.execution.junit2.info.MethodLocation; +import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.runners.ExecutionEnvironmentBuilder; import com.intellij.execution.testframework.TestSearchScope; +import com.intellij.execution.testframework.sm.runner.SMRunnerConsolePropertiesProvider; +import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties; import com.intellij.openapi.components.PathMacroManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; @@ -49,7 +52,7 @@ import org.jetbrains.annotations.NotNull; import java.util.*; public class JUnitConfiguration extends ModuleBasedConfiguration - implements CommonJavaRunConfigurationParameters, RefactoringListenerProvider { + implements CommonJavaRunConfigurationParameters, RefactoringListenerProvider, SMRunnerConsolePropertiesProvider { public static final String DEFAULT_PACKAGE_NAME = ExecutionBundle.message("default.package.presentable.name"); @NonNls public static final String TEST_CLASS = "class"; @@ -449,6 +452,11 @@ public class JUnitConfiguration extends ModuleBasedConfiguration - implements CommonJavaRunConfigurationParameters, RefactoringListenerProvider { + implements CommonJavaRunConfigurationParameters, RefactoringListenerProvider, SMRunnerConsolePropertiesProvider { @NonNls private static final String PATTERNS_EL_NAME = "patterns"; @NonNls private static final String PATTERN_EL_NAME = "pattern"; @NonNls private static final String TEST_CLASS_ATT_NAME = "testClass"; @@ -419,4 +422,9 @@ public class TestNGConfiguration extends ModuleBasedConfiguration - + - - + \ No newline at end of file