use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class PyAbstractTestProcessRunner method formatLevel.
private static void formatLevel(@NotNull final SMTestProxy test, final int level, @NotNull final StringBuilder builder) {
builder.append(StringUtil.repeat(".", level));
builder.append(test.getName());
if (test.isLeaf()) {
builder.append(test.isPassed() ? "(+)" : "(-)");
}
builder.append('\n');
for (SMTestProxy child : test.getChildren()) {
formatLevel(child, level + 1, builder);
}
}
use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class TestsPresentationUtil method getPresentableName.
@NotNull
public static String getPresentableName(final SMTestProxy testProxy) {
final SMTestProxy parent = testProxy.getParent();
final String name = testProxy.getName();
if (name == null) {
return NO_NAME_TEST;
}
String presentationCandidate = name;
if (parent != null) {
String parentName = parent.getName();
if (parentName != null) {
boolean parentStartsWith = name.startsWith(parentName);
if (!parentStartsWith && parent instanceof SMTestProxy.SMRootTestProxy) {
final String presentation = ((SMTestProxy.SMRootTestProxy) parent).getPresentation();
if (presentation != null) {
parentName = presentation;
parentStartsWith = name.startsWith(parentName);
if (!parentStartsWith) {
String comment = ((SMTestProxy.SMRootTestProxy) parent).getComment();
if (comment != null) {
parentName = StringUtil.getQualifiedName(comment, presentation);
parentStartsWith = name.startsWith(parentName);
}
}
}
}
if (parentStartsWith) {
presentationCandidate = name.substring(parentName.length());
// remove "." separator
presentationCandidate = StringUtil.trimStart(presentationCandidate, ".");
}
}
}
// trim
presentationCandidate = presentationCandidate.trim();
// remove extra spaces
presentationCandidate = presentationCandidate.replaceAll("\\s+", " ");
if (StringUtil.isEmpty(presentationCandidate)) {
return NO_NAME_TEST;
}
return presentationCandidate;
}
use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class TestsPresentationUtil method appendSuiteStatusColorPresentation.
public static void appendSuiteStatusColorPresentation(final SMTestProxy proxy, final ColoredTableCellRenderer renderer) {
int passedCount = 0;
int errorsCount = 0;
int failedCount = 0;
int ignoredCount = 0;
if (proxy.isLeaf()) {
// If suite is empty show <no tests> label and exit from method
renderer.append(RESULTS_NO_TESTS, proxy.wasLaunched() ? PASSED_ATTRIBUTES : DEFFECT_ATTRIBUTES);
return;
}
final List<SMTestProxy> allTestCases = proxy.getAllTests();
for (SMTestProxy testOrSuite : allTestCases) {
// we should ignore test suites
if (testOrSuite.isSuite()) {
continue;
}
// if test check it state
switch(testOrSuite.getMagnitudeInfo()) {
case COMPLETE_INDEX:
case PASSED_INDEX:
passedCount++;
break;
case ERROR_INDEX:
errorsCount++;
break;
case FAILED_INDEX:
failedCount++;
break;
case IGNORED_INDEX:
case SKIPPED_INDEX:
ignoredCount++;
break;
case NOT_RUN_INDEX:
case TERMINATED_INDEX:
case RUNNING_INDEX:
//Do nothing
break;
}
}
final String separator = " ";
if (failedCount > 0) {
renderer.append(SMTestsRunnerBundle.message("sm.test.runner.ui.tabs.statistics.columns.results.count.msg.failed", failedCount) + separator, DEFFECT_ATTRIBUTES);
}
if (errorsCount > 0) {
renderer.append(SMTestsRunnerBundle.message("sm.test.runner.ui.tabs.statistics.columns.results.count.msg.errors", errorsCount) + separator, DEFFECT_ATTRIBUTES);
}
if (ignoredCount > 0) {
renderer.append(SMTestsRunnerBundle.message("sm.test.runner.ui.tabs.statistics.columns.results.count.msg.ignored", ignoredCount) + separator, SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES);
}
if (passedCount > 0) {
renderer.append(SMTestsRunnerBundle.message("sm.test.runner.ui.tabs.statistics.columns.results.count.msg.passed", passedCount), PASSED_ATTRIBUTES);
}
}
use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class FileUrlLocationTest method doTest.
private void doTest(int expectedOffset, String filePath, int lineNum) {
SMTestProxy testProxy = new SMTestProxy("myTest", false, "file://" + filePath + ":" + lineNum);
testProxy.setLocator(FileUrlProvider.INSTANCE);
Location location = testProxy.getLocation(getProject(), GlobalSearchScope.allScope(getProject()));
assertNotNull(location);
PsiElement element = location.getPsiElement();
assertNotNull(element);
assertEquals(expectedOffset, element.getTextOffset());
}
use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class SMTRunnerUIActionsHandlerTest method testSelectFirstDefect_Priority_Error.
public void testSelectFirstDefect_Priority_Error() {
// Priority: error -> failure
TestConsoleProperties.SELECT_FIRST_DEFECT.set(myProperties, true);
mySuite.setStarted();
final SMTestProxy testsSuite = createSuiteProxy("my suite", mySuite);
testsSuite.setStarted();
// pending test
final SMTestProxy testPending = createTestProxy("testPending", testsSuite);
testPending.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testPending);
testPending.setTestIgnored("", "");
//failed test
final SMTestProxy testFailed = createTestProxy("testFailed", testsSuite);
testFailed.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testFailed);
testFailed.setTestFailed("", "", false);
//error test
final SMTestProxy testError = createTestProxy("testError", testsSuite);
testError.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testError);
testError.setTestFailed("", "", true);
// Second error test just to check that first failed will be selected
final SMTestProxy testError2 = createTestProxy("testError2", testsSuite);
testError2.setStarted();
myUIActionsHandler.onTestNodeAdded(myResultsViewer, testError2);
testError2.setTestFailed("", "", true);
// finish suite
testsSuite.setFinished();
assertNull(mySelectedTestProxy);
//testing finished
mySuite.setFinished();
assertNull(mySelectedTestProxy);
myUIActionsHandler.onTestingFinished(myResultsViewer);
assertEquals(testError, mySelectedTestProxy);
}
Aggregations