import/export tests: include successful configs according to setting; allow to change view after import accordingly

This commit is contained in:
Anna Kozlova
2015-07-01 21:31:42 +03:00
parent 01d259f8cc
commit 5fb0775e6f
9 changed files with 42 additions and 28 deletions
@@ -31,7 +31,6 @@ import com.intellij.execution.ui.ConsoleView;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.project.Project;
import com.intellij.pom.Navigatable;
import com.intellij.util.config.ToggleBooleanProperty;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -116,9 +115,9 @@ public class ImportedTestConsoleProperties extends SMTRunnerConsoleProperties im
}
@Override
public void appendAdditionalActions(DefaultActionGroup actionGroup, JComponent parent) {
public void appendAdditionalActions(DefaultActionGroup actionGroup, JComponent parent, TestConsoleProperties target) {
if (myProperties != null) {
myProperties.appendAdditionalActions(actionGroup, parent);
myProperties.appendAdditionalActions(actionGroup, parent, this);
}
}
}
@@ -52,7 +52,12 @@ public class ImportedTestContentHandler extends DefaultHandler {
myCurrentTest = name;
myDuration = attributes.getValue(TestResultsXmlFormatter.ATTR_DURATION);
myStatus = attributes.getValue(TestResultsXmlFormatter.ATTR_STATUS);
myProcessor.onTestStarted(new TestStartedEvent(name, attributes.getValue(TestResultsXmlFormatter.ATTR_LOCATION)));
final String isConfig = attributes.getValue(TestResultsXmlFormatter.ATTR_CONFIG);
final TestStartedEvent startedEvent = new TestStartedEvent(name, attributes.getValue(TestResultsXmlFormatter.ATTR_LOCATION));
if (isConfig != null && Boolean.valueOf(isConfig)) {
startedEvent.setConfig(true);
}
myProcessor.onTestStarted(startedEvent);
currentValue.setLength(0);
}
else if (TestResultsXmlFormatter.ELEM_OUTPUT.equals(qName)) {
@@ -777,12 +777,14 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
private static class MySaveHistoryTask extends Task.Backgroundable {
private final TestConsoleProperties myConsoleProperties;
private SMTestProxy.SMRootTestProxy myRoot;
private RunConfiguration myConfiguration;
private String myOutput;
public MySaveHistoryTask(TestConsoleProperties consoleProperties, SMTestProxy.SMRootTestProxy root, RunConfiguration configuration) {
super(consoleProperties.getProject(), "Save Test Results", true);
myConsoleProperties = consoleProperties;
myRoot = root;
myConfiguration = configuration;
}
@@ -800,7 +802,7 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
final SMTestProxy.SMRootTestProxy root = myRoot;
final RunConfiguration configuration = myConfiguration;
if (root != null && configuration != null) {
TestResultsXmlFormatter.execute(root, configuration, handler);
TestResultsXmlFormatter.execute(root, configuration, myConsoleProperties, handler);
}
myOutput = w.toString();
}
@@ -195,7 +195,7 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
myUsePredefinedMessageFilter = usePredefinedMessageFilter;
}
public void appendAdditionalActions(DefaultActionGroup actionGroup, JComponent parent) { }
public void appendAdditionalActions(DefaultActionGroup actionGroup, JComponent parent, TestConsoleProperties target) { }
@Nullable
protected AnAction createImportAction() {
@@ -203,16 +203,16 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
}
@NotNull
protected ToggleBooleanProperty createIncludeNonStartedInRerun() {
protected ToggleBooleanProperty createIncludeNonStartedInRerun(TestConsoleProperties target) {
String text = ExecutionBundle.message("junit.runing.info.include.non.started.in.rerun.failed.action.name");
return new ToggleBooleanProperty(text, null, null, this, INCLUDE_NON_STARTED_IN_RERUN_FAILED);
return new ToggleBooleanProperty(text, null, null, target, INCLUDE_NON_STARTED_IN_RERUN_FAILED);
}
@NotNull
protected ToggleBooleanProperty createHideSuccessfulConfig() {
protected ToggleBooleanProperty createHideSuccessfulConfig(TestConsoleProperties target) {
String text = ExecutionBundle.message("junit.runing.info.hide.successful.config.action.name");
setIfUndefined(HIDE_SUCCESSFUL_CONFIG, true);
return new ToggleBooleanProperty(text, null, null, this, HIDE_SUCCESSFUL_CONFIG);
return new ToggleBooleanProperty(text, null, null, target, HIDE_SUCCESSFUL_CONFIG);
}
@JdkConstants.TreeSelectionMode
@@ -23,7 +23,6 @@ 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;
import com.intellij.execution.testframework.actions.TestFrameworkActions;
@@ -155,7 +154,7 @@ public class ToolbarPanel extends JPanel implements OccurenceNavigator, Disposab
secondaryGroup.addSeparator();
secondaryGroup.add(new ToggleBooleanProperty(ExecutionBundle.message("junit.runing.info.select.first.failed.action.name"),
null, null, properties, TestConsoleProperties.SELECT_FIRST_DEFECT));
properties.appendAdditionalActions(secondaryGroup, parent);
properties.appendAdditionalActions(secondaryGroup, parent, properties);
actionGroup.add(secondaryGroup);
add(ActionManager.getInstance().
@@ -307,7 +307,7 @@ public class ExportTestResultsAction extends DumbAwareAction {
StringWriter w = new StringWriter();
handler.setResult(new StreamResult(w));
try {
TestResultsXmlFormatter.execute(myModel.getRoot(), myRunConfiguration, handler);
TestResultsXmlFormatter.execute(myModel.getRoot(), myRunConfiguration, myModel.getProperties(), handler);
}
catch (ProcessCanceledException e) {
return null;
@@ -18,12 +18,10 @@ package com.intellij.execution.testframework.export;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.filters.*;
import com.intellij.execution.filters.Filter;
import com.intellij.execution.impl.RunManagerImpl;
import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
import com.intellij.execution.testframework.AbstractTestProxy;
import com.intellij.execution.testframework.Printable;
import com.intellij.execution.testframework.Printer;
import com.intellij.execution.testframework.TestProxyRoot;
import com.intellij.execution.testframework.*;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.extensions.Extensions;
@@ -59,6 +57,7 @@ public class TestResultsXmlFormatter {
public static final String ATTR_STATUS = "status";
public static final String TOTAL_STATUS = "total";
private static final String ATTR_FOORTER_TEXT = "footerText";
public static final String ATTR_CONFIG = "isConfig";
public static final String STATUS_PASSED = "passed";
public static final String STATUS_FAILED = "failed";
public static final String STATUS_ERROR = "error";
@@ -72,16 +71,21 @@ public class TestResultsXmlFormatter {
private final RunConfiguration myRuntimeConfiguration;
private final ContentHandler myResultHandler;
private final AbstractTestProxy myTestRoot;
private final boolean myHidePassedConfig;
public static void execute(AbstractTestProxy root, RunConfiguration runtimeConfiguration, ContentHandler resultHandler)
public static void execute(AbstractTestProxy root, RunConfiguration runtimeConfiguration, TestConsoleProperties properties, ContentHandler resultHandler)
throws SAXException {
new TestResultsXmlFormatter(root, runtimeConfiguration, resultHandler).execute();
new TestResultsXmlFormatter(root, runtimeConfiguration, properties, resultHandler).execute();
}
private TestResultsXmlFormatter(AbstractTestProxy root, RunConfiguration runtimeConfiguration, ContentHandler resultHandler) {
private TestResultsXmlFormatter(AbstractTestProxy root,
RunConfiguration runtimeConfiguration,
TestConsoleProperties properties,
ContentHandler resultHandler) {
myRuntimeConfiguration = runtimeConfiguration;
myTestRoot = root;
myResultHandler = resultHandler;
myHidePassedConfig = TestConsoleProperties.HIDE_SUCCESSFUL_CONFIG.value(properties);
}
private void execute() throws SAXException {
@@ -205,6 +209,9 @@ public class TestResultsXmlFormatter {
if (locationUrl != null) {
attrs.put(ATTR_LOCATION, locationUrl);
}
if (node.isConfig()) {
attrs.put(ATTR_CONFIG, "true");
}
String elemName = node.isLeaf() ? ELEM_TEST : ELEM_SUITE;
startElement(elemName, attrs);
if (node.isLeaf()) {
@@ -250,7 +257,7 @@ public class TestResultsXmlFormatter {
}
else {
for (AbstractTestProxy child : node.getChildren()) {
if (child.isConfig() && child.isPassed()) {
if (myHidePassedConfig && child.isConfig() && child.isPassed()) {
//ignore configurations during export
continue;
}
@@ -21,6 +21,7 @@ import com.intellij.execution.junit2.ui.actions.RerunFailedTestsAction;
import com.intellij.execution.testframework.JavaAwareTestConsoleProperties;
import com.intellij.execution.testframework.JavaTestLocator;
import com.intellij.execution.testframework.SourceScope;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction;
import com.intellij.execution.testframework.sm.runner.SMTestLocator;
import com.intellij.execution.ui.ConsoleView;
@@ -59,9 +60,9 @@ public class JUnitConsoleProperties extends JavaAwareTestConsoleProperties<JUnit
@Override
public void appendAdditionalActions(DefaultActionGroup actionGroup,
JComponent parent) {
super.appendAdditionalActions(actionGroup, parent);
actionGroup.add(createIncludeNonStartedInRerun());
JComponent parent, TestConsoleProperties target) {
super.appendAdditionalActions(actionGroup, parent, target);
actionGroup.add(createIncludeNonStartedInRerun(target));
}
@Override
@@ -19,6 +19,7 @@ import com.intellij.execution.Executor;
import com.intellij.execution.testframework.JavaAwareTestConsoleProperties;
import com.intellij.execution.testframework.JavaTestLocator;
import com.intellij.execution.testframework.SourceScope;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction;
import com.intellij.execution.testframework.sm.runner.SMTestLocator;
import com.intellij.execution.ui.ConsoleView;
@@ -55,11 +56,11 @@ public class TestNGConsoleProperties extends JavaAwareTestConsoleProperties<Test
}
@Override
public void appendAdditionalActions(DefaultActionGroup actionGroup, JComponent parent) {
super.appendAdditionalActions(actionGroup, parent);
actionGroup.add(createIncludeNonStartedInRerun());
public void appendAdditionalActions(DefaultActionGroup actionGroup, JComponent parent, TestConsoleProperties target) {
super.appendAdditionalActions(actionGroup, parent, target);
actionGroup.add(createIncludeNonStartedInRerun(target));
actionGroup.add(Separator.getInstance());
actionGroup.add(createHideSuccessfulConfig());
actionGroup.add(createHideSuccessfulConfig(target));
}
@Nullable