Search in sources :

Example 1 with TestFinishedEvent

use of com.carrotsearch.ant.tasks.junit4.events.TestFinishedEvent in project randomizedtesting by randomizedtesting.

the class TextReport method emitBufferedEvents.

private void emitBufferedEvents(AggregatedSuiteResultEvent e) throws IOException {
    final IdentityHashMap<TestFinishedEvent, AggregatedTestResultEvent> eventMap = new IdentityHashMap<>();
    for (AggregatedTestResultEvent tre : e.getTests()) {
        eventMap.put(tre.getTestFinishedEvent(), tre);
    }
    final boolean emitOutput = (outputMode != OutputMode.NEVER) && ((outputMode == OutputMode.ALWAYS && !isPassthrough()) || (outputMode == OutputMode.ONERROR && !e.isSuccessful()));
    for (IEvent event : e.getEventStream()) {
        switch(event.getType()) {
            case APPEND_STDOUT:
                if (emitOutput)
                    ((IStreamEvent) event).copyTo(outStream);
                break;
            case APPEND_STDERR:
                if (emitOutput)
                    ((IStreamEvent) event).copyTo(errStream);
                break;
            case TEST_FINISHED:
                assert eventMap.containsKey(event);
                final AggregatedTestResultEvent aggregated = eventMap.get(event);
                if (displayStatus.get(aggregated.getStatus())) {
                    flushOutput();
                    emitStatusLine(aggregated, aggregated.getStatus(), aggregated.getExecutionTime());
                }
            default:
                break;
        }
    }
    if (emitOutput) {
        flushOutput();
    }
}
Also used : AggregatedTestResultEvent(com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedTestResultEvent) IEvent(com.carrotsearch.ant.tasks.junit4.events.IEvent) TestFinishedEvent(com.carrotsearch.ant.tasks.junit4.events.TestFinishedEvent) IdentityHashMap(java.util.IdentityHashMap)

Aggregations

IEvent (com.carrotsearch.ant.tasks.junit4.events.IEvent)1 TestFinishedEvent (com.carrotsearch.ant.tasks.junit4.events.TestFinishedEvent)1 AggregatedTestResultEvent (com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedTestResultEvent)1 IdentityHashMap (java.util.IdentityHashMap)1