Search in sources :

Example 1 with FailureEvent

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

the class AggregatedSuiteResultEvent method serializeEvents.

private void serializeEvents(JsonWriter w, boolean outputStreams) throws IOException {
    final Charset charset = getSlave().getCharset();
    int lineBuffer = 160;
    final StringWriter out = new StringWriter();
    final StringWriter err = new StringWriter();
    WriterOutputStream stdout = new WriterOutputStream(out, charset, lineBuffer, false);
    WriterOutputStream stderr = new WriterOutputStream(err, charset, lineBuffer, false);
    for (IEvent evt : getEventStream()) {
        try {
            switch(evt.getType()) {
                case SUITE_FAILURE:
                case TEST_IGNORED_ASSUMPTION:
                case TEST_IGNORED:
                case TEST_STARTED:
                case TEST_FINISHED:
                case TEST_FAILURE:
                    flushBoth(w, out, err, stdout, stderr);
                    w.beginObject();
                    w.name("event").value(evt.getType().toString());
                    w.name("description");
                    JsonHelpers.writeDescription(w, ((IDescribable) evt).getDescription());
                    if (evt instanceof FailureEvent) {
                        w.name("failure");
                        ((FailureEvent) evt).serialize(w);
                    }
                    w.endObject();
                    break;
                case APPEND_STDOUT:
                    if (outputStreams) {
                        flush(APPEND_STDERR, w, stderr, err);
                        ((IStreamEvent) evt).copyTo(stdout);
                    }
                    break;
                case APPEND_STDERR:
                    if (outputStreams) {
                        flush(APPEND_STDOUT, w, stdout, out);
                        ((IStreamEvent) evt).copyTo(stderr);
                    }
                    break;
                default:
                    break;
            }
        } catch (IOException ex) {
        // Ignore.
        }
    }
    flushBoth(w, out, err, stdout, stderr);
}
Also used : StringWriter(java.io.StringWriter) IEvent(com.carrotsearch.ant.tasks.junit4.events.IEvent) IStreamEvent(com.carrotsearch.ant.tasks.junit4.events.IStreamEvent) FailureEvent(com.carrotsearch.ant.tasks.junit4.events.FailureEvent) Charset(java.nio.charset.Charset) IOException(java.io.IOException) WriterOutputStream(com.carrotsearch.randomizedtesting.WriterOutputStream)

Aggregations

FailureEvent (com.carrotsearch.ant.tasks.junit4.events.FailureEvent)1 IEvent (com.carrotsearch.ant.tasks.junit4.events.IEvent)1 IStreamEvent (com.carrotsearch.ant.tasks.junit4.events.IStreamEvent)1 WriterOutputStream (com.carrotsearch.randomizedtesting.WriterOutputStream)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Charset (java.nio.charset.Charset)1