Search in sources :

Example 6 with SMTestProxy

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);
    }
}
Also used : SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy)

Example 7 with SMTestProxy

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;
}
Also used : SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with SMTestProxy

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);
    }
}
Also used : SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy)

Example 9 with SMTestProxy

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());
}
Also used : SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy) PsiElement(com.intellij.psi.PsiElement) Location(com.intellij.execution.Location)

Example 10 with SMTestProxy

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);
}
Also used : SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy)

Aggregations

SMTestProxy (com.intellij.execution.testframework.sm.runner.SMTestProxy)42 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)9 Project (com.intellij.openapi.project.Project)8 Location (com.intellij.execution.Location)6 PsiClass (com.intellij.psi.PsiClass)6 MethodLocation (com.intellij.execution.junit2.info.MethodLocation)5 PsiMemberParameterizedLocation (com.intellij.execution.junit2.PsiMemberParameterizedLocation)4 PsiElement (com.intellij.psi.PsiElement)4 PsiMethod (com.intellij.psi.PsiMethod)4 JavaTestLocator (com.intellij.execution.testframework.JavaTestLocator)3 List (java.util.List)3 AbstractTestProxy (com.intellij.execution.testframework.AbstractTestProxy)2 SMTRunnerTreeStructure (com.intellij.execution.testframework.sm.runner.SMTRunnerTreeStructure)2 Ref (com.intellij.openapi.util.Ref)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 NotNull (org.jetbrains.annotations.NotNull)2 ExecutionException (com.intellij.execution.ExecutionException)1 JavaTestConfigurationBase (com.intellij.execution.JavaTestConfigurationBase)1