Search in sources :

Example 61 with Description

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);
        }
    }
}
Also used : Description(org.junit.runner.Description) ArrayDeque(java.util.ArrayDeque)

Example 62 with 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);
}
Also used : Description(org.junit.runner.Description)

Example 63 with Description

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;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Description(org.junit.runner.Description) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException)

Example 64 with Description

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;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Description(org.junit.runner.Description) ComparisonFailure(org.junit.ComparisonFailure) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException)

Example 65 with Description

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;
}
Also used : Description(org.junit.runner.Description) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Aggregations

Description (org.junit.runner.Description)309 Test (org.junit.Test)119 Failure (org.junit.runner.notification.Failure)57 Result (org.junit.runner.Result)32 ArrayList (java.util.ArrayList)25 RunListener (org.junit.runner.notification.RunListener)23 IOException (java.io.IOException)22 Request (org.junit.runner.Request)21 Method (java.lang.reflect.Method)18 JUnitCore (org.junit.runner.JUnitCore)17 Test (org.junit.jupiter.api.Test)14 Filter (org.junit.runner.manipulation.Filter)14 File (java.io.File)13 Runner (org.junit.runner.Runner)13 Statement (org.junit.runners.model.Statement)13 LoggingListener (org.elasticsearch.test.junit.listeners.LoggingListener)12 RunNotifier (org.junit.runner.notification.RunNotifier)12 JUnit4TestListener (com.intellij.junit4.JUnit4TestListener)10 ComparisonFailure (org.junit.ComparisonFailure)10 Description.createTestDescription (org.junit.runner.Description.createTestDescription)9