use of org.junit.runner.Description in project spf4j by zolyfarkas.
the class Spf4jTestLogRunListenerSingleton method testFailure.
@Override
public void testFailure(final Failure failure) {
Description description = failure.getDescription();
LogCollection<ArrayDeque<LogRecord>> handler = collections.get(description);
if (handler != null) {
// will Happen when a Uncaught Exception causes a test to fail.
try (LogCollection<ArrayDeque<LogRecord>> h = handler) {
dumpDebugInfo(h.get(), description);
}
}
}
use of org.junit.runner.Description in project n4js by eclipse.
the class ExecutionResults method executionFailed.
/**
* Mark execution of given {@link Description} as failed. Parent descriptions may be updated accordingly.
*/
public void executionFailed(Failure failure) {
Description description = failure.getDescription();
allStatuses.put(description, ExecutionStatus.FAILED);
allFailures.put(description, failure);
updateParents(description, ExecutionStatus.FAILED);
}
use of org.junit.runner.Description in project n4js by eclipse.
the class GenerateXpectReportCommandHandler method execute.
/**
* When called will check if provided data contains {@link Description test description} with failed status stored
* in {@link N4IDEXpectView test view}. If that holds, will generate data for bug report in a console view,
* otherwise will show message to reconfigure and rerun Xpect tests.
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
try {
view = (N4IDEXpectView) windows[0].getActivePage().showView(N4IDEXpectView.ID);
} catch (PartInitException e) {
N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
}
Description desc = (Description) selection.getFirstElement();
// handle failed suite
if (desc.isSuite()) {
final N4IDEXpectView finalview = view;
boolean suitePassed = desc.getChildren().stream().noneMatch(childDescription -> finalview.testsExecutionStatus.hasFailed(childDescription));
if (suitePassed) {
XpectFileContentsUtil.getXpectFileContentAccess(desc).ifPresent(xpectFielContentAccess -> {
if (xpectFielContentAccess.containsFixme()) {
generateAndDisplayReport(N4IDEXpectFileNameUtil.getSuiteName(desc), xpectFielContentAccess.getContetns());
}
});
} else {
XpectConsole console = ConsoleDisplayMgr.getOrCreate("generated bug for " + N4IDEXpectFileNameUtil.getSuiteName(desc));
console.clear();
String ls = System.lineSeparator();
console.log("Suite must be passing and contain XPECT FIXME marker to be submited bug report. Please :" + ls + " - fix failing tests" + ls + " - mark test in question with XPECT FIXME");
}
}
return null;
}
use of org.junit.runner.Description in project n4js by eclipse.
the class XpectCompareCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
try {
view = (N4IDEXpectView) windows[0].getActivePage().showView(N4IDEXpectView.ID);
} catch (PartInitException e) {
N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
}
Description desc = (Description) selection.getFirstElement();
if (desc.isTest() && view.testsExecutionStatus.hasFailed(desc)) {
Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();
if (failureException instanceof ComparisonFailure) {
ComparisonFailure cf = (ComparisonFailure) failureException;
// display comparison view
displayComparisonView(cf, desc);
}
}
return null;
}
use of org.junit.runner.Description in project n4js by eclipse.
the class XpectLabelProvider method getImageDescriptor.
/**
* get icon based on item type (test/suite) and its status (pass/failed/exception/skip/in progress...)
*/
private ImageDescriptor getImageDescriptor(Object element) throws RuntimeException {
ImageDescriptor descriptor = null;
if (element instanceof Description == false) {
String msg = "Unknown type of element in tree of type " + element.getClass().getName();
Exception e = new RuntimeException(msg);
N4IDEXpectUIPlugin.logError("cannot obtain image descriptor, fallback to default", e);
return getImageDescriptor("n4_logo.png");
}
Description desc = (Description) element;
if (desc.isTest()) {
descriptor = getTestImageDescriptor(executionStatus.getStatus(desc));
} else if (desc.isSuite()) {
descriptor = getSuiteImageDescriptor(desc, executionStatus.getStatus(desc));
} else {
descriptor = getImageDescriptor("n4_logo.png");
}
return descriptor;
}
Aggregations