Search in sources :

Example 1 with TestCase

use of org.eclipse.n4js.tester.domain.TestCase in project n4js by eclipse.

the class TestTreeTransformerTest method createTestTree.

private TestTree createTestTree(final Multimap<String, String> suiteToCasesMapping) {
    checkArgument(!suiteToCasesMapping.isEmpty());
    final TestTree tree = new TestTree(new ID(randomUUID().toString()));
    final List<TestSuite> suites = newArrayList();
    suiteToCasesMapping.asMap().entrySet().forEach(entry -> {
        final TestSuite suite = new TestSuite(entry.getKey());
        entry.getValue().forEach(testCaseName -> suite.add(new TestCase(new ID(testCaseName), "class.name." + suite.getName(), "project.origin." + suite.getName(), testCaseName, "display.name." + testCaseName, URI.createURI("testURI_" + testCaseName))));
        suites.add(suite);
    });
    tree.getSuites().addAll(suites);
    return tree;
}
Also used : TestSuite(org.eclipse.n4js.tester.domain.TestSuite) TestCase(org.eclipse.n4js.tester.domain.TestCase) ID(org.eclipse.n4js.tester.domain.ID) UUID.randomUUID(java.util.UUID.randomUUID) TestTree(org.eclipse.n4js.tester.domain.TestTree)

Example 2 with TestCase

use of org.eclipse.n4js.tester.domain.TestCase in project n4js by eclipse.

the class TesterDomainTest method newTestCase.

private Collection<? extends TestCase> newTestCase(final String testId, final String... otherIds) {
    final List<TestCase> cases = newArrayList();
    asList(testId, otherIds).forEach(id -> cases.add(new TestCase(new ID(id), "className." + id, "origin." + id, "name." + id, "displayName." + id, URI.createURI("testURI_" + id))));
    return cases;
}
Also used : TestCase(org.eclipse.n4js.tester.domain.TestCase) ID(org.eclipse.n4js.tester.domain.ID) UUID.randomUUID(java.util.UUID.randomUUID)

Example 3 with TestCase

use of org.eclipse.n4js.tester.domain.TestCase in project n4js by eclipse.

the class ResultNode method updateResult.

public void updateResult(TestResult newResult) {
    final TestCase tc = getTestCase();
    if (tc != null) {
        tc.setResult(newResult);
        // perform necessary updates (also in ancestors) ...
        refreshCachedStatus();
    }
}
Also used : TestCase(org.eclipse.n4js.tester.domain.TestCase)

Example 4 with TestCase

use of org.eclipse.n4js.tester.domain.TestCase in project n4js by eclipse.

the class TestDiscoveryHelper method collectSuitsForModule.

private Collection<TestSuite> collectSuitsForModule(final TModule module) {
    final List<TestSuite> suites = newArrayList();
    // Collect all top level non-abstract exported classes, exclude everything else.
    for (final TClass clazz : from(module.getTopLevelTypes()).filter(TClass.class).filter(c -> !c.isAbstract() && c.isExported())) {
        final TestSuite testSuite = new TestSuite(getClassName(clazz));
        for (final TMethod method : getAllTestMethodsOfClass(clazz)) {
            final TestCase testCase = createTestCase(method, module, getClassName(clazz));
            testSuite.add(testCase);
        }
        if (!isEmpty(testSuite)) {
            suites.add(testSuite);
        }
    }
    return suites;
}
Also used : TMethod(org.eclipse.n4js.ts.types.TMethod) TestSuite(org.eclipse.n4js.tester.domain.TestSuite) TestCase(org.eclipse.n4js.tester.domain.TestCase) TClass(org.eclipse.n4js.ts.types.TClass)

Example 5 with TestCase

use of org.eclipse.n4js.tester.domain.TestCase in project n4js by eclipse.

the class TestResultsView method onSingleClick.

/**
 * Invoked when user double-clicks a result node in the UI.
 *
 * On invocation clears stack trace text are. If selection is a test case with stack trace, trace is shown in the
 * trace area.
 */
protected void onSingleClick() {
    stackTrace.setText("");
    final ISelection selection = testTreeViewer.getSelection();
    if (selection.isEmpty()) {
        return;
    }
    if (selection instanceof IStructuredSelection) {
        final Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof ResultNode) {
            final ResultNode resultNode = (ResultNode) element;
            final TestElement testElement = resultNode.getElement();
            if (testElement instanceof TestCase) {
                final TestCase testCase = (TestCase) testElement;
                final TestResult result = testCase.getResult();
                if (result != null) {
                    if (result.getTrace() != null && !result.getTrace().isEmpty()) {
                        final List<String> trace = newArrayList(result.getTrace());
                        final String firstLine = trace.get(0);
                        if ("Error".equals(firstLine) && !isNullOrEmpty(result.getMessage())) {
                            trace.set(0, result.getMessage());
                        }
                        final StringBuilder sb = new StringBuilder();
                        trace.forEach(line -> sb.append(line).append(lineSeparator()));
                        stackTrace.setText(sb.toString());
                        stackTrace.setSelection(0);
                    } else if ((SKIPPED_IGNORE.equals(result.getTestStatus()) || SKIPPED_FIXME.equals(result.getTestStatus())) && !isNullOrEmpty(result.getMessage())) {
                        stackTrace.setText(result.getMessage());
                        stackTrace.setSelection(0);
                    }
                }
            }
        }
    }
}
Also used : TestCase(org.eclipse.n4js.tester.domain.TestCase) ISelection(org.eclipse.jface.viewers.ISelection) TestResult(org.eclipse.n4js.tester.domain.TestResult) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TestElement(org.eclipse.n4js.tester.domain.TestElement)

Aggregations

TestCase (org.eclipse.n4js.tester.domain.TestCase)11 UUID.randomUUID (java.util.UUID.randomUUID)5 ID (org.eclipse.n4js.tester.domain.ID)5 TestSuite (org.eclipse.n4js.tester.domain.TestSuite)5 TestTree (org.eclipse.n4js.tester.domain.TestTree)4 ISelection (org.eclipse.jface.viewers.ISelection)2 TestElement (org.eclipse.n4js.tester.domain.TestElement)2 Function (com.google.common.base.Function)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IFile (org.eclipse.core.resources.IFile)1 URI (org.eclipse.emf.common.util.URI)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TestResult (org.eclipse.n4js.tester.domain.TestResult)1 TClass (org.eclipse.n4js.ts.types.TClass)1 TMethod (org.eclipse.n4js.ts.types.TMethod)1 IN4JSEclipseProject (org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject)1 Test (org.junit.Test)1