mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit statistics: total labels
This commit is contained in:
@@ -114,39 +114,81 @@ public class TestsUIUtil {
|
||||
String text;
|
||||
String balloonText;
|
||||
MessageType type;
|
||||
if (root == null) {
|
||||
balloonText = title = ExecutionBundle.message("test.not.started.progress.text");
|
||||
text = "";
|
||||
type = MessageType.WARNING;
|
||||
} else{
|
||||
List allTests = Filter.LEAF.select(root.getAllTests());
|
||||
final List<AbstractTestProxy> failed = Filter.DEFECTIVE_LEAF.select(allTests);
|
||||
int failedCount = failed.size();
|
||||
final List<AbstractTestProxy> notStarted = Filter.NOT_PASSED.select(allTests);
|
||||
notStarted.removeAll(failed);
|
||||
int notStartedCount = notStarted.size();
|
||||
int passedCount = allTests.size() - failedCount - notStartedCount;
|
||||
if (failedCount > 0) {
|
||||
title = ExecutionBundle.message("junit.runing.info.tests.failed.label");
|
||||
text = passedCount + " passed, " + failedCount + " failed" + (notStartedCount > 0 ? ", " + notStartedCount + " not started" : "");
|
||||
type = MessageType.ERROR;
|
||||
}
|
||||
else if (notStartedCount > 0) {
|
||||
title = ExecutionBundle.message("junit.runing.info.failed.to.start.error.message");
|
||||
text = passedCount + " passed, " + notStartedCount + " not started" ;
|
||||
type = MessageType.ERROR;
|
||||
}
|
||||
else {
|
||||
title = ExecutionBundle.message("junit.runing.info.tests.passed.label");
|
||||
text = passedCount + " passed";
|
||||
type = MessageType.INFO;
|
||||
}
|
||||
balloonText = title + ": " + text;
|
||||
}
|
||||
TestResultPresentation testResultPresentation = new TestResultPresentation(root).getPresentation();
|
||||
type = testResultPresentation.getType();
|
||||
balloonText = testResultPresentation.getBalloonText();
|
||||
title = testResultPresentation.getTitle();
|
||||
text = testResultPresentation.getText();
|
||||
|
||||
if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
|
||||
toolWindowManager.notifyByBalloon(testRunDebugId, type, balloonText, null, null);
|
||||
}
|
||||
SystemNotifications.getInstance().notify("TestRunner", title, text);
|
||||
}
|
||||
|
||||
public static String getTestSummary(AbstractTestProxy proxy) {
|
||||
return new TestResultPresentation(proxy).getPresentation().getBalloonText();
|
||||
}
|
||||
|
||||
private static class TestResultPresentation {
|
||||
private AbstractTestProxy myRoot;
|
||||
private String myTitle;
|
||||
private String myText;
|
||||
private String myBalloonText;
|
||||
private MessageType myType;
|
||||
|
||||
public TestResultPresentation(AbstractTestProxy root) {
|
||||
myRoot = root;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return myTitle;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return myText;
|
||||
}
|
||||
|
||||
public String getBalloonText() {
|
||||
return myBalloonText;
|
||||
}
|
||||
|
||||
public MessageType getType() {
|
||||
return myType;
|
||||
}
|
||||
|
||||
public TestResultPresentation getPresentation() {
|
||||
if (myRoot == null) {
|
||||
myBalloonText = myTitle = ExecutionBundle.message("test.not.started.progress.text");
|
||||
myText = "";
|
||||
myType = MessageType.WARNING;
|
||||
} else{
|
||||
List allTests = Filter.LEAF.select(myRoot.getAllTests());
|
||||
final List<AbstractTestProxy> failed = Filter.DEFECTIVE_LEAF.select(allTests);
|
||||
int failedCount = failed.size();
|
||||
final List<AbstractTestProxy> notStarted = Filter.NOT_PASSED.select(allTests);
|
||||
notStarted.removeAll(failed);
|
||||
int notStartedCount = notStarted.size();
|
||||
int passedCount = allTests.size() - failedCount - notStartedCount;
|
||||
if (failedCount > 0) {
|
||||
myTitle = ExecutionBundle.message("junit.runing.info.tests.failed.label");
|
||||
myText = passedCount + " passed, " + failedCount + " failed" + (notStartedCount > 0 ? ", " + notStartedCount + " not started" : "");
|
||||
myType = MessageType.ERROR;
|
||||
}
|
||||
else if (notStartedCount > 0) {
|
||||
myTitle = ExecutionBundle.message("junit.runing.info.failed.to.start.error.message");
|
||||
myText = passedCount + " passed, " + notStartedCount + " not started" ;
|
||||
myType = MessageType.ERROR;
|
||||
}
|
||||
else {
|
||||
myTitle = ExecutionBundle.message("junit.runing.info.tests.passed.label");
|
||||
myText = passedCount + " passed";
|
||||
myType = MessageType.INFO;
|
||||
}
|
||||
myBalloonText = myTitle + ": " + myText;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import com.intellij.execution.testframework.TestsUIUtil;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.openapi.ui.VerticalFlowLayout;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.table.BaseTableView;
|
||||
import com.intellij.ui.table.TableView;
|
||||
import com.intellij.util.config.Storage;
|
||||
@@ -46,6 +46,8 @@ class StatisticsPanel extends JPanel implements DataProvider{
|
||||
private JUnitRunningModel myModel;
|
||||
private final TableView myTable;
|
||||
private final Storage.PropertiesComponentStorage myStorage = new Storage.PropertiesComponentStorage("junit_statistics_table_columns");
|
||||
private SimpleColoredComponent myTotalLabel;
|
||||
private SimpleColoredComponent myTimeLabel;
|
||||
|
||||
public StatisticsPanel() {
|
||||
super(new BorderLayout(0, 0));
|
||||
@@ -60,17 +62,30 @@ class StatisticsPanel extends JPanel implements DataProvider{
|
||||
IdeActions.GROUP_TESTSTATISTICS_POPUP,
|
||||
ActionPlaces.TESTSTATISTICS_VIEW_POPUP);
|
||||
// add(myTestCaseInfo, BorderLayout.NORTH);
|
||||
add(myTable, BorderLayout.CENTER);
|
||||
add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
|
||||
final JPanel eastPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
|
||||
|
||||
myTotalLabel = new SimpleColoredComponent();
|
||||
eastPanel.add(myTotalLabel);
|
||||
|
||||
myTimeLabel = new SimpleColoredComponent();
|
||||
eastPanel.add(myTimeLabel);
|
||||
|
||||
add(eastPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
private void updateStatistics() {
|
||||
myTable.setVisible(true);
|
||||
// myTestCaseInfo.setVisible(false);
|
||||
TestProxy proxy = myCurrentTest;
|
||||
if (myCurrentTest.isLeaf() && myCurrentTest.getParent() != null) {
|
||||
myChildInfo.updateStatistics(myCurrentTest.getParent());
|
||||
} else{
|
||||
myChildInfo.updateStatistics(myCurrentTest);
|
||||
proxy = myCurrentTest.getParent();
|
||||
}
|
||||
myChildInfo.updateStatistics(proxy);
|
||||
myTotalLabel.clear();
|
||||
myTotalLabel.append(TestsUIUtil.getTestSummary(proxy), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
myTimeLabel.clear();
|
||||
myTimeLabel.append("Total time: " + Formatters.statisticsFor(proxy).getTime(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
final int idx = myChildInfo.getIndexOf(myCurrentTest);
|
||||
TableUtil.selectRows(myTable, new int[]{idx});
|
||||
TableUtil.scrollSelectionToVisible(myTable);
|
||||
|
||||
Reference in New Issue
Block a user