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;
}
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;
}
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();
}
}
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;
}
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);
}
}
}
}
}
}
Aggregations