org.gradle.api.tasks.testing.TestOutputEvent Java Examples
The following examples show how to use
org.gradle.api.tasks.testing.TestOutputEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestOutputStore.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void onOutput(long classId, long testId, TestOutputEvent outputEvent) { boolean stdout = outputEvent.getDestination() == TestOutputEvent.Destination.StdOut; mark(classId, testId, stdout); output.writeBoolean(stdout); output.writeSmallLong(classId); output.writeSmallLong(testId); byte[] bytes; try { bytes = outputEvent.getMessage().getBytes(messageStorageCharset.name()); } catch (UnsupportedEncodingException e) { throw UncheckedException.throwAsUncheckedException(e); } output.writeSmallInt(bytes.length); output.writeBytes(bytes, 0, bytes.length); }
Example #2
Source File: TestOutputStore.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void onOutput(long classId, long testId, TestOutputEvent outputEvent) { boolean stdout = outputEvent.getDestination() == TestOutputEvent.Destination.StdOut; mark(classId, testId, stdout); output.writeBoolean(stdout); output.writeSmallLong(classId); output.writeSmallLong(testId); byte[] bytes; try { bytes = outputEvent.getMessage().getBytes(messageStorageCharset.name()); } catch (UnsupportedEncodingException e) { throw UncheckedException.throwAsUncheckedException(e); } output.writeSmallInt(bytes.length); output.writeBytes(bytes, 0, bytes.length); }
Example #3
Source File: JUnitXmlResultWriter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void writeOutputs(SimpleXmlWriter writer, long classId, boolean allClassOutput, TestOutputEvent.Destination destination) throws IOException { writer.startCDATA(); if (allClassOutput) { testResultsProvider.writeAllOutput(classId, destination, writer); } else { testResultsProvider.writeNonTestOutput(classId, destination, writer); } writer.endCDATA(); }
Example #4
Source File: JUnitXmlResultWriter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void writeOutputs(SimpleXmlWriter writer, long classId, boolean allClassOutput, TestOutputEvent.Destination destination) throws IOException { writer.startCDATA(); if (allClassOutput) { testResultsProvider.writeAllOutput(classId, destination, writer); } else { testResultsProvider.writeNonTestOutput(classId, destination, writer); } writer.endCDATA(); }
Example #5
Source File: AggregateTestResultsProvider.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean hasOutput(long id, final TestOutputEvent.Destination destination) { return Iterables.any( classOutputProviders.get(id), new Predicate<DelegateProvider>() { public boolean apply(DelegateProvider delegateProvider) { return delegateProvider.provider.hasOutput(delegateProvider.id, destination); } }); }
Example #6
Source File: JUnitXmlResultWriter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void write(TestClassResult result, OutputStream output) { String className = result.getClassName(); long classId = result.getId(); try { SimpleXmlWriter writer = new SimpleXmlWriter(output, " "); writer.startElement("testsuite") .attribute("name", className) .attribute("tests", String.valueOf(result.getTestsCount())) .attribute("skipped", String.valueOf(result.getSkippedCount())) .attribute("failures", String.valueOf(result.getFailuresCount())) .attribute("errors", "0") .attribute("timestamp", DateUtils.format(result.getStartTime(), DateUtils.ISO8601_DATETIME_PATTERN)) .attribute("hostname", hostName) .attribute("time", String.valueOf(result.getDuration() / 1000.0)); writer.startElement("properties"); writer.endElement(); writeTests(writer, result.getResults(), className, classId); writer.startElement("system-out"); writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdOut); writer.endElement(); writer.startElement("system-err"); writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdErr); writer.endElement(); writer.endElement(); } catch (IOException e) { throw UncheckedException.throwAsUncheckedException(e); } }
Example #7
Source File: JUnitXmlResultWriter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void writeOutputs(SimpleXmlWriter writer, long classId, boolean allClassOutput, TestOutputEvent.Destination destination) throws IOException { writer.startCDATA(); if (allClassOutput) { testResultsProvider.writeAllOutput(classId, destination, writer); } else { testResultsProvider.writeNonTestOutput(classId, destination, writer); } writer.endCDATA(); }
Example #8
Source File: JUnitXmlResultWriter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void writeTests(SimpleXmlWriter writer, Iterable<TestMethodResult> methodResults, String className, long classId) throws IOException { for (TestMethodResult methodResult : methodResults) { writer.startElement("testcase") .attribute("name", methodResult.getName()) .attribute("classname", className) .attribute("time", String.valueOf(methodResult.getDuration() / 1000.0)); if (methodResult.getResultType() == TestResult.ResultType.SKIPPED) { writer.startElement("skipped"); writer.endElement(); } else { for (TestFailure failure : methodResult.getFailures()) { writer.startElement("failure") .attribute("message", failure.getMessage()) .attribute("type", failure.getExceptionType()); writer.characters(failure.getStackTrace()); writer.endElement(); } } if (outputAssociation.equals(TestOutputAssociation.WITH_TESTCASE)) { writer.startElement("system-out"); writeOutputs(writer, classId, methodResult.getId(), TestOutputEvent.Destination.StdOut); writer.endElement(); writer.startElement("system-err"); writeOutputs(writer, classId, methodResult.getId(), TestOutputEvent.Destination.StdErr); writer.endElement(); } writer.endElement(); } }
Example #9
Source File: ClassPageRenderer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void registerTabs() { addFailuresTab(); addTab("Tests", new ErroringAction<SimpleHtmlWriter>() { public void doExecute(SimpleHtmlWriter writer) throws IOException { renderTests(writer); } }); if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdOut)) { addTab("Standard output", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter htmlWriter) throws IOException { htmlWriter.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdOut, htmlWriter); htmlWriter.endElement() .endElement(); } }); } if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdErr)) { addTab("Standard error", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter element) throws Exception { element.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdErr, element); element.endElement() .endElement(); } }); } }
Example #10
Source File: JUnitXmlResultWriter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void writeOutputs(SimpleXmlWriter writer, long classId, boolean allClassOutput, TestOutputEvent.Destination destination) throws IOException { writer.startCDATA(); if (allClassOutput) { testResultsProvider.writeAllOutput(classId, destination, writer); } else { testResultsProvider.writeNonTestOutput(classId, destination, writer); } writer.endCDATA(); }
Example #11
Source File: TestOutputStore.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean hasOutput(long classId, TestOutputEvent.Destination destination) { if (dataFile == null) { return false; } Index classIndex = index.children.get(classId); if (classIndex == null) { return false; } else { Region region = destination == TestOutputEvent.Destination.StdOut ? classIndex.stdOut : classIndex.stdErr; return region.start >= 0; } }
Example #12
Source File: ClassPageRenderer.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void registerTabs() { addFailuresTab(); addTab("Tests", new ErroringAction<SimpleHtmlWriter>() { public void doExecute(SimpleHtmlWriter writer) throws IOException { renderTests(writer); } }); if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdOut)) { addTab("Standard output", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter htmlWriter) throws IOException { htmlWriter.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdOut, htmlWriter); htmlWriter.endElement() .endElement(); } }); } if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdErr)) { addTab("Standard error", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter element) throws Exception { element.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdErr, element); element.endElement() .endElement(); } }); } }
Example #13
Source File: AggregateTestResultsProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean hasOutput(long id, final TestOutputEvent.Destination destination) { return Iterables.any( classOutputProviders.get(id), new Predicate<DelegateProvider>() { public boolean apply(DelegateProvider delegateProvider) { return delegateProvider.provider.hasOutput(delegateProvider.id, destination); } }); }
Example #14
Source File: JUnitXmlResultWriter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void write(TestClassResult result, OutputStream output) { String className = result.getClassName(); long classId = result.getId(); try { SimpleXmlWriter writer = new SimpleXmlWriter(output, " "); writer.startElement("testsuite") .attribute("name", className) .attribute("tests", String.valueOf(result.getTestsCount())) .attribute("skipped", String.valueOf(result.getSkippedCount())) .attribute("failures", String.valueOf(result.getFailuresCount())) .attribute("errors", "0") .attribute("timestamp", DateUtils.format(result.getStartTime(), DateUtils.ISO8601_DATETIME_PATTERN)) .attribute("hostname", hostName) .attribute("time", String.valueOf(result.getDuration() / 1000.0)); writer.startElement("properties"); writer.endElement(); writeTests(writer, result.getResults(), className, classId); writer.startElement("system-out"); writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdOut); writer.endElement(); writer.startElement("system-err"); writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdErr); writer.endElement(); writer.endElement(); } catch (IOException e) { throw UncheckedException.throwAsUncheckedException(e); } }
Example #15
Source File: TestOutputStore.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean hasOutput(long classId, TestOutputEvent.Destination destination) { if (dataFile == null) { return false; } Index classIndex = index.children.get(classId); if (classIndex == null) { return false; } else { Region region = destination == TestOutputEvent.Destination.StdOut ? classIndex.stdOut : classIndex.stdErr; return region.start >= 0; } }
Example #16
Source File: ClassPageRenderer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void registerTabs() { addFailuresTab(); addTab("Tests", new ErroringAction<SimpleHtmlWriter>() { public void doExecute(SimpleHtmlWriter writer) throws IOException { renderTests(writer); } }); final long classId = getModel().getId(); if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdOut)) { addTab("Standard output", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter htmlWriter) throws IOException { htmlWriter.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdOut, htmlWriter); htmlWriter.endElement() .endElement(); } }); } if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdErr)) { addTab("Standard error", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter element) throws Exception { element.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdErr, element); element.endElement() .endElement(); } }); } }
Example #17
Source File: InMemoryTestResultsProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public boolean hasOutput(long id, TestOutputEvent.Destination destination) { return outputReader.hasOutput(id, destination); }
Example #18
Source File: InMemoryTestResultsProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void writeTestOutput(long classId, long testId, TestOutputEvent.Destination destination, Writer writer) { outputReader.writeTestOutput(classId, testId, destination, writer); }
Example #19
Source File: InMemoryTestResultsProvider.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void writeTestOutput(long classId, long testId, TestOutputEvent.Destination destination, Writer writer) { outputReader.writeTestOutput(classId, testId, destination, writer); }
Example #20
Source File: AggregateTestResultsProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void writeAllOutput(long id, TestOutputEvent.Destination destination, Writer writer) { for (DelegateProvider delegateProvider : classOutputProviders.get(id)) { delegateProvider.provider.writeAllOutput(delegateProvider.id, destination, writer); } }
Example #21
Source File: StateTrackingTestResultProcessor.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public final void output(Object testId, TestOutputEvent event) { output(findDescriptor(testId), event); }
Example #22
Source File: CaptureTestOutputTestResultProcessor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void onOutput(CharSequence output) { processor.output(testId, new DefaultTestOutputEvent(TestOutputEvent.Destination.StdErr, output.toString())); }
Example #23
Source File: TestOutputStore.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
private void doRead(long classId, long testId, boolean allClassOutput, TestOutputEvent.Destination destination, java.io.Writer writer) { if (dataFile == null) { return; } Index targetIndex = index.children.get(classId); if (targetIndex != null && testId != 0) { targetIndex = targetIndex.children.get(testId); } if (targetIndex == null) { return; } boolean stdout = destination == TestOutputEvent.Destination.StdOut; Region region = stdout ? targetIndex.stdOut : targetIndex.stdErr; if (region.start < 0) { return; } boolean ignoreClassLevel = !allClassOutput && testId != 0; boolean ignoreTestLevel = !allClassOutput && testId == 0; try { dataFile.seek(region.start); long maxPos = region.stop - region.start; KryoBackedDecoder decoder = new KryoBackedDecoder(new RandomAccessFileInputStream(dataFile)); while (decoder.getReadPosition() <= maxPos) { boolean readStdout = decoder.readBoolean(); long readClassId = decoder.readSmallLong(); long readTestId = decoder.readSmallLong(); int readLength = decoder.readSmallInt(); boolean isClassLevel = readTestId == 0; if (stdout != readStdout || classId != readClassId) { decoder.skipBytes(readLength); continue; } if (ignoreClassLevel && isClassLevel) { decoder.skipBytes(readLength); continue; } if (ignoreTestLevel && !isClassLevel) { decoder.skipBytes(readLength); continue; } if (testId == 0 || testId == readTestId) { byte[] stringBytes = new byte[readLength]; decoder.readBytes(stringBytes); String message; try { message = new String(stringBytes, messageStorageCharset.name()); } catch (UnsupportedEncodingException e) { // shouldn't happen throw UncheckedException.throwAsUncheckedException(e); } writer.write(message); } else { decoder.skipBytes(readLength); } } } catch (IOException e1) { throw new UncheckedIOException(e1); } }
Example #24
Source File: AggregateTestResultsProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void writeNonTestOutput(long id, TestOutputEvent.Destination destination, Writer writer) { for (DelegateProvider delegateProvider : classOutputProviders.get(id)) { delegateProvider.provider.writeNonTestOutput(delegateProvider.id, destination, writer); } }
Example #25
Source File: BinaryResultBackedTestResultsProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public boolean hasOutput(long id, TestOutputEvent.Destination destination) { return outputReader.hasOutput(id, destination); }
Example #26
Source File: BinaryResultBackedTestResultsProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void writeTestOutput(long classId, long testId, TestOutputEvent.Destination destination, Writer writer) { outputReader.writeTestOutput(classId, testId, destination, writer); }
Example #27
Source File: AggregateTestResultsProvider.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void writeTestOutput(long classId, long testId, TestOutputEvent.Destination destination, Writer writer) { for (DelegateProvider delegateProvider : classOutputProviders.get(classId)) { delegateProvider.provider.writeTestOutput(delegateProvider.id, testId, destination, writer); } }
Example #28
Source File: AggregateTestResultsProvider.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void writeNonTestOutput(long id, TestOutputEvent.Destination destination, Writer writer) { for (DelegateProvider delegateProvider : classOutputProviders.get(id)) { delegateProvider.provider.writeNonTestOutput(delegateProvider.id, destination, writer); } }
Example #29
Source File: TestOutputStore.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void writeAllOutput(long classId, TestOutputEvent.Destination destination, java.io.Writer writer) { doRead(classId, 0, true, destination, writer); }
Example #30
Source File: AggregateTestResultsProvider.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void writeAllOutput(long id, TestOutputEvent.Destination destination, Writer writer) { for (DelegateProvider delegateProvider : classOutputProviders.get(id)) { delegateProvider.provider.writeAllOutput(delegateProvider.id, destination, writer); } }