org.gradle.api.tasks.testing.TestResult Java Examples
The following examples show how to use
org.gradle.api.tasks.testing.TestResult.
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: TestNGTestResultProcessorAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 8 votes |
private void onTestFinished(ITestResult iTestResult, TestResult.ResultType resultType) { Object testId; TestStartEvent startEvent = null; synchronized (lock) { testId = tests.remove(iTestResult); if (testId == null) { // This can happen when a method fails which this method depends on testId = idGenerator.generateId(); Object parentId = testMethodToSuiteMapping.get(iTestResult.getMethod()); startEvent = new TestStartEvent(iTestResult.getStartMillis(), parentId); } } if (startEvent != null) { // Synthesize a start event resultProcessor.started(new DefaultTestMethodDescriptor(testId, iTestResult.getTestClass().getName(), iTestResult.getName()), startEvent); } if (resultType == TestResult.ResultType.FAILURE) { resultProcessor.failure(testId, iTestResult.getThrowable()); } resultProcessor.completed(testId, new TestCompleteEvent(iTestResult.getEndMillis(), resultType)); }
Example #2
Source File: TestResultSerializer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private TestMethodResult readMethodResult(Decoder decoder) throws ClassNotFoundException, IOException { long id = decoder.readSmallLong(); String name = decoder.readString(); TestResult.ResultType resultType = TestResult.ResultType.values()[decoder.readSmallInt()]; long duration = decoder.readSmallLong(); long endTime = decoder.readLong(); TestMethodResult methodResult = new TestMethodResult(id, name, resultType, duration, endTime); int failures = decoder.readSmallInt(); for (int i = 0; i < failures; i++) { String exceptionType = decoder.readString(); String message = decoder.readString(); String stackTrace = decoder.readString(); methodResult.addFailure(message, stackTrace, exceptionType); } return methodResult; }
Example #3
Source File: TestResultSerializer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private TestMethodResult readMethodResult(Decoder decoder) throws ClassNotFoundException, IOException { long id = decoder.readSmallLong(); String name = decoder.readString(); TestResult.ResultType resultType = TestResult.ResultType.values()[decoder.readSmallInt()]; long duration = decoder.readSmallLong(); long endTime = decoder.readLong(); TestMethodResult methodResult = new TestMethodResult(id, name, resultType, duration, endTime); int failures = decoder.readSmallInt(); for (int i = 0; i < failures; i++) { String exceptionType = decoder.readString(); String message = decoder.readString(); String stackTrace = decoder.readString(); methodResult.addFailure(message, stackTrace, exceptionType); } return methodResult; }
Example #4
Source File: TestNGTestResultProcessorAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void onTestFinished(ITestResult iTestResult, TestResult.ResultType resultType) { Object testId; TestStartEvent startEvent = null; synchronized (lock) { testId = tests.remove(iTestResult); if (testId == null) { // This can happen when a method fails which this method depends on testId = idGenerator.generateId(); Object parentId = testMethodToSuiteMapping.get(iTestResult.getMethod()); startEvent = new TestStartEvent(iTestResult.getStartMillis(), parentId); } } if (startEvent != null) { // Synthesize a start event resultProcessor.started(new DefaultTestMethodDescriptor(testId, iTestResult.getTestClass().getName(), iTestResult.getName()), startEvent); } if (resultType == TestResult.ResultType.FAILURE) { resultProcessor.failure(testId, iTestResult.getThrowable()); } resultProcessor.completed(testId, new TestCompleteEvent(iTestResult.getEndMillis(), resultType)); }
Example #5
Source File: TestNGTestResultProcessorAdapter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void onTestFinished(ITestResult iTestResult, TestResult.ResultType resultType) { Object testId; TestStartEvent startEvent = null; synchronized (lock) { testId = tests.remove(iTestResult); if (testId == null) { // This can happen when a method fails which this method depends on testId = idGenerator.generateId(); Object parentId = testMethodToSuiteMapping.get(iTestResult.getMethod()); startEvent = new TestStartEvent(iTestResult.getStartMillis(), parentId); } } if (startEvent != null) { // Synthesize a start event resultProcessor.started(new DefaultTestMethodDescriptor(testId, iTestResult.getTestClass().getName(), iTestResult.getName()), startEvent); } if (resultType == TestResult.ResultType.FAILURE) { resultProcessor.failure(testId, iTestResult.getThrowable()); } resultProcessor.completed(testId, new TestCompleteEvent(iTestResult.getEndMillis(), resultType)); }
Example #6
Source File: GradleTestSuiteCollector.java From gradle-metrics-plugin with Apache License 2.0 | 6 votes |
@VisibleForTesting Result getTestResult(TestResult testResult) { TestResult.ResultType testResultType = testResult.getResultType(); List<Throwable> exceptions = testResult.getExceptions(); Result result; switch (testResultType) { case SUCCESS: result = Result.success(); break; case SKIPPED: result = Result.skipped(); break; case FAILURE: //noinspection ConstantConditions result = Result.failure(exceptions); break; default: logger.warn("Test result carried unknown result type '{}'. Assuming success", testResultType); result = Result.success(); } return result; }
Example #7
Source File: TestCountLogger.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void afterSuite(TestDescriptor suite, TestResult result) { if (suite.getParent() == null) { if (failedTests > 0) { logger.error(TextUtil.getPlatformLineSeparator() + summary()); } progressLogger.completed(); if (result.getResultType() == TestResult.ResultType.FAILURE) { hadFailures = true; } } }
Example #8
Source File: TestClassResult.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public TestClassResult add(TestMethodResult methodResult) { if (methodResult.getResultType() == TestResult.ResultType.FAILURE) { failuresCount++; } if(methodResult.getResultType() == TestResult.ResultType.SKIPPED) { skippedCount++; } methodResults.add(methodResult); return this; }
Example #9
Source File: TestEventLogger.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private TestLogEvent getEvent(TestResult result) { switch (result.getResultType()) { case SUCCESS: return TestLogEvent.PASSED; case FAILURE: return TestLogEvent.FAILED; case SKIPPED: return TestLogEvent.SKIPPED; default: throw new AssertionError(); } }
Example #10
Source File: TestState.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void completed(TestCompleteEvent event) { this.completeEvent = event; resultType = isFailed() ? TestResult.ResultType.FAILURE : event.getResultType() != null ? event.getResultType() : TestResult.ResultType.SUCCESS; if (!test.isComposite()) { testCount = 1; switch (resultType) { case SUCCESS: successfulCount = 1; break; case FAILURE: failedCount = 1; break; } } if (startEvent.getParentId() != null) { TestState parentState = executing.get(startEvent.getParentId()); if (parentState != null) { if (isFailed()) { parentState.failedChild = true; } parentState.testCount += testCount; parentState.successfulCount += successfulCount; parentState.failedCount += failedCount; } } }
Example #11
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 #12
Source File: JUnitTestEventAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void testIgnored(Description description) throws Exception { if (methodName(description) == null) { // An @Ignored class, ignore the event. We don't get testIgnored events for each method, so we have // generate them on our own processIgnoredClass(description); return; } TestDescriptorInternal testInternal = descriptor(idGenerator.generateId(), description); resultProcessor.started(testInternal, startEvent()); resultProcessor.completed(testInternal.getId(), new TestCompleteEvent(timeProvider.getCurrentTime(), TestResult.ResultType.SKIPPED)); }
Example #13
Source File: JUnitTestEventAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void testIgnored(Description description) throws Exception { if (methodName(description) == null) { // An @Ignored class, ignore the event. We don't get testIgnored events for each method, so we have // generate them on our own processIgnoredClass(description); return; } TestDescriptorInternal testInternal = descriptor(idGenerator.generateId(), description); resultProcessor.started(testInternal, startEvent()); resultProcessor.completed(testInternal.getId(), new TestCompleteEvent(timeProvider.getCurrentTime(), TestResult.ResultType.SKIPPED)); }
Example #14
Source File: TestCountLogger.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void afterSuite(TestDescriptor suite, TestResult result) { if (suite.getParent() == null) { if (failedTests > 0) { logger.error(TextUtil.getPlatformLineSeparator() + summary()); } progressLogger.completed(); if (result.getResultType() == TestResult.ResultType.FAILURE) { hadFailures = true; } } }
Example #15
Source File: TestMethodResult.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public TestMethodResult(long id, String name, TestResult.ResultType resultType, long duration, long endTime) { if (id < 1) { throw new IllegalArgumentException("id must be > 0"); } this.id = id; this.name = name; this.resultType = resultType; this.duration = duration; this.endTime = endTime; }
Example #16
Source File: JUnitXmlResultWriter.java From pushfish-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 #17
Source File: TestMethodResult.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public TestMethodResult(long id, String name, TestResult.ResultType resultType, long duration, long endTime) { if (id < 1) { throw new IllegalArgumentException("id must be > 0"); } this.id = id; this.name = name; this.resultType = resultType; this.duration = duration; this.endTime = endTime; }
Example #18
Source File: TestEventLogger.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private TestLogEvent getEvent(TestResult result) { switch (result.getResultType()) { case SUCCESS: return TestLogEvent.PASSED; case FAILURE: return TestLogEvent.FAILED; case SKIPPED: return TestLogEvent.SKIPPED; default: throw new AssertionError(); } }
Example #19
Source File: TestState.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void completed(TestCompleteEvent event) { this.completeEvent = event; resultType = isFailed() ? TestResult.ResultType.FAILURE : event.getResultType() != null ? event.getResultType() : TestResult.ResultType.SUCCESS; if (!test.isComposite()) { testCount = 1; switch (resultType) { case SUCCESS: successfulCount = 1; break; case FAILURE: failedCount = 1; break; } } if (startEvent.getParentId() != null) { TestState parentState = executing.get(startEvent.getParentId()); if (parentState != null) { if (isFailed()) { parentState.failedChild = true; } parentState.testCount += testCount; parentState.successfulCount += successfulCount; parentState.failedCount += failedCount; } } }
Example #20
Source File: TestMethodResult.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public TestMethodResult(long id, String name, TestResult.ResultType resultType, long duration, long endTime) { if (id < 1) { throw new IllegalArgumentException("id must be > 0"); } this.id = id; this.name = name; this.resultType = resultType; this.duration = duration; this.endTime = endTime; }
Example #21
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 #22
Source File: TestState.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void completed(TestCompleteEvent event) { this.completeEvent = event; resultType = isFailed() ? TestResult.ResultType.FAILURE : event.getResultType() != null ? event.getResultType() : TestResult.ResultType.SUCCESS; if (!test.isComposite()) { testCount = 1; switch (resultType) { case SUCCESS: successfulCount = 1; break; case FAILURE: failedCount = 1; break; } } if (startEvent.getParentId() != null) { TestState parentState = executing.get(startEvent.getParentId()); if (parentState != null) { if (isFailed()) { parentState.failedChild = true; } parentState.testCount += testCount; parentState.successfulCount += successfulCount; parentState.failedCount += failedCount; } } }
Example #23
Source File: TestClassResult.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public TestClassResult add(TestMethodResult methodResult) { if (methodResult.getResultType() == TestResult.ResultType.FAILURE) { failuresCount++; } if(methodResult.getResultType() == TestResult.ResultType.SKIPPED) { skippedCount++; } methodResults.add(methodResult); return this; }
Example #24
Source File: TestNGTestResultProcessorAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void onConfigurationFailure(ITestResult testResult) { if (failedConfigurations.put(testResult, true) != null) { // workaround for bug in TestNG 6.2 (apparently fixed in some 6.3.x): listener is notified twice per event return; } // Synthesise a test for the broken configuration method TestDescriptorInternal test = new DefaultTestMethodDescriptor(idGenerator.generateId(), testResult.getMethod().getTestClass().getName(), testResult.getMethod().getMethodName()); resultProcessor.started(test, new TestStartEvent(testResult.getStartMillis())); resultProcessor.failure(test.getId(), testResult.getThrowable()); resultProcessor.completed(test.getId(), new TestCompleteEvent(testResult.getEndMillis(), TestResult.ResultType.FAILURE)); }
Example #25
Source File: GradleTestSuiteCollector.java From gradle-metrics-plugin with Apache License 2.0 | 5 votes |
@Override public void afterTest(TestDescriptor testDescriptor, TestResult testResult) { checkNotNull(testDescriptor); checkNotNull(testResult); Result result = getTestResult(testResult); org.gradle.api.tasks.testing.Test testTask = (org.gradle.api.tasks.testing.Test) task; String suiteName = testTask.getName(); long startTime = testResult.getStartTime(); long elapsed = testResult.getEndTime() - startTime; Test test = new Test(testDescriptor.getName(), testDescriptor.getClassName(), suiteName, result, new DateTime(startTime), elapsed); dispatcherSupplier.get().test(test); }
Example #26
Source File: TestNGTestResultProcessorAdapter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void onConfigurationFailure(ITestResult testResult) { if (failedConfigurations.put(testResult, true) != null) { // workaround for bug in TestNG 6.2 (apparently fixed in some 6.3.x): listener is notified twice per event return; } // Synthesise a test for the broken configuration method TestDescriptorInternal test = new DefaultTestMethodDescriptor(idGenerator.generateId(), testResult.getMethod().getTestClass().getName(), testResult.getMethod().getMethodName()); resultProcessor.started(test, new TestStartEvent(testResult.getStartMillis())); resultProcessor.failure(test.getId(), testResult.getThrowable()); resultProcessor.completed(test.getId(), new TestCompleteEvent(testResult.getEndMillis(), TestResult.ResultType.FAILURE)); }
Example #27
Source File: ErrorReportingTestListener.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void afterTest(TestDescriptor testDescriptor, TestResult result) { // Include test failure exception stacktrace(s) in test output log. if (result.getResultType() == TestResult.ResultType.FAILURE) { if (result.getExceptions().size() > 0) { String message = formatter.format(testDescriptor, result.getExceptions()); handlerFor(testDescriptor).write(message); } } }
Example #28
Source File: TestClassResult.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public TestClassResult add(TestMethodResult methodResult) { if (methodResult.getResultType() == TestResult.ResultType.FAILURE) { failuresCount++; } if(methodResult.getResultType() == TestResult.ResultType.SKIPPED) { skippedCount++; } methodResults.add(methodResult); return this; }
Example #29
Source File: JUnitTestEventAdapter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void testIgnored(Description description) throws Exception { if (methodName(description) == null) { // An @Ignored class, ignore the event. We don't get testIgnored events for each method, so we have // generate them on our own processIgnoredClass(description); return; } TestDescriptorInternal testInternal = descriptor(idGenerator.generateId(), description); resultProcessor.started(testInternal, startEvent()); resultProcessor.completed(testInternal.getId(), new TestCompleteEvent(timeProvider.getCurrentTime(), TestResult.ResultType.SKIPPED)); }
Example #30
Source File: TestNGTestResultProcessorAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void onConfigurationFailure(ITestResult testResult) { if (failedConfigurations.put(testResult, true) != null) { // workaround for bug in TestNG 6.2 (apparently fixed in some 6.3.x): listener is notified twice per event return; } // Synthesise a test for the broken configuration method TestDescriptorInternal test = new DefaultTestMethodDescriptor(idGenerator.generateId(), testResult.getMethod().getTestClass().getName(), testResult.getMethod().getMethodName()); resultProcessor.started(test, new TestStartEvent(testResult.getStartMillis())); resultProcessor.failure(test.getId(), testResult.getThrowable()); resultProcessor.completed(test.getId(), new TestCompleteEvent(testResult.getEndMillis(), TestResult.ResultType.FAILURE)); }