testng: unify notifications

This commit is contained in:
anna
2013-07-03 19:29:50 +02:00
parent 0114d6c6d9
commit 4e5e0bab51
3 changed files with 7 additions and 19 deletions
@@ -226,7 +226,7 @@ public class TestsUIUtil {
myType = MessageType.INFO;
}
if (myComment != null) {
myText += " (" + myComment + ")";
myText += " " + myComment;
}
myBalloonText = myTitle + ": " + myText;
}
@@ -161,25 +161,8 @@ public class TestNGRunnableState extends JavaCommandLineState {
final TestConsoleProperties consoleProperties = console.getProperties();
if (consoleProperties == null) return;
final String testRunDebugId = consoleProperties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN;
final TestNGResults resultsView = console.getResultsView();
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
final MessageType type = resultsView == null || resultsView.getStatus() == MessageHelper.SKIPPED_TEST
? MessageType.WARNING
: (resultsView.getStatus() == MessageHelper.FAILED_TEST
? MessageType.ERROR
: MessageType.INFO);
final String message;
if (resultsView == null) {
message = myStarted ? "Tests were interrupted" : "Tests were not started";
}
else {
message = resultsView.getStatusLine();
}
toolWindowManager.notifyByBalloon(testRunDebugId, type, message, null, null);
TestsUIUtil.NOTIFICATION_GROUP.createNotification(message, type).notify(project);
}
TestsUIUtil.notifyByBalloon(project, myStarted, console.getResultsView().getRoot(), consoleProperties, "in " + resultsView.getTime());
}
};
SwingUtilities.invokeLater(notificationRunnable);
@@ -209,6 +209,11 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
}
return sb.toString();
}
public String getTime() {
final long time = end - start;
return time == 0 ? "0.0 s" : NumberFormat.getInstance().format((double)time / 1000.0) + " s";
}
public TestProxy testStarted(TestResultMessage result) {
return testStarted(result, true);