org.gradle.api.tasks.testing.TestDescriptor Java Examples
The following examples show how to use
org.gradle.api.tasks.testing.TestDescriptor.
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: AbstractTestLogger.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private String getEventPath(TestDescriptor descriptor) { List<String> names = Lists.newArrayList(); TestDescriptor current = descriptor; while (current != null) { if (isAtomicTestWhoseParentIsNotTheTestClass(current)) { // This deals with the fact that in TestNG, there are no class-level events, // but we nevertheless want to see the class name. We use "." rather than // " > " as a separator to make it clear that the class is not a separate // level. This matters when configuring granularity. names.add(current.getClassName() + "." + current.getName()); } else { names.add(current.getName()); } current = current.getParent(); } int effectiveDisplayGranularity = displayGranularity == -1 ? names.size() - 1 : Math.min(displayGranularity, names.size() - 1); List<String> displayedNames = Lists.reverse(names).subList(effectiveDisplayGranularity, names.size()); return Joiner.on(" > ").join(displayedNames) + " "; }
Example #2
Source File: AbstractTestLogger.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private String getEventPath(TestDescriptor descriptor) { List<String> names = Lists.newArrayList(); TestDescriptor current = descriptor; while (current != null) { if (isAtomicTestWhoseParentIsNotTheTestClass(current)) { // This deals with the fact that in TestNG, there are no class-level events, // but we nevertheless want to see the class name. We use "." rather than // " > " as a separator to make it clear that the class is not a separate // level. This matters when configuring granularity. names.add(current.getClassName() + "." + current.getName()); } else { names.add(current.getName()); } current = current.getParent(); } int effectiveDisplayGranularity = displayGranularity == -1 ? names.size() - 1 : Math.min(displayGranularity, names.size() - 1); List<String> displayedNames = Lists.reverse(names).subList(effectiveDisplayGranularity, names.size()); return Joiner.on(" > ").join(displayedNames) + " "; }
Example #3
Source File: AbstractTestLogger.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private String getEventPath(TestDescriptor descriptor) { List<String> names = Lists.newArrayList(); TestDescriptor current = descriptor; while (current != null) { if (isAtomicTestWhoseParentIsNotTheTestClass(current)) { // This deals with the fact that in TestNG, there are no class-level events, // but we nevertheless want to see the class name. We use "." rather than // " > " as a separator to make it clear that the class is not a separate // level. This matters when configuring granularity. names.add(current.getClassName() + "." + current.getName()); } else { names.add(current.getName()); } current = current.getParent(); } int effectiveDisplayGranularity = displayGranularity == -1 ? names.size() - 1 : Math.min(displayGranularity, names.size() - 1); List<String> displayedNames = Lists.reverse(names).subList(effectiveDisplayGranularity, names.size()); return Joiner.on(" > ").join(displayedNames) + " "; }
Example #4
Source File: ShortExceptionFormatter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void printException(TestDescriptor descriptor, Throwable exception, boolean cause, int indentLevel, StringBuilder builder) { String indent = Strings.repeat(INDENT, indentLevel); builder.append(indent); if (cause) { builder.append("Caused by: "); } String className = exception instanceof PlaceholderException ? ((PlaceholderException) exception).getExceptionClassName() : exception.getClass().getName(); builder.append(className); StackTraceFilter filter = new StackTraceFilter(new ClassMethodNameStackTraceSpec(descriptor.getClassName(), null)); List<StackTraceElement> stackTrace = filter.filter(exception); if (stackTrace.size() > 0) { StackTraceElement element = stackTrace.get(0); builder.append(" at "); builder.append(element.getFileName()); builder.append(':'); builder.append(element.getLineNumber()); } builder.append('\n'); if (testLogging.getShowCauses() && exception.getCause() != null) { printException(descriptor, exception.getCause(), true, indentLevel + 1, builder); } }
Example #5
Source File: ShortExceptionFormatter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void printException(TestDescriptor descriptor, Throwable exception, boolean cause, int indentLevel, StringBuilder builder) { String indent = Strings.repeat(INDENT, indentLevel); builder.append(indent); if (cause) { builder.append("Caused by: "); } String className = exception instanceof PlaceholderException ? ((PlaceholderException) exception).getExceptionClassName() : exception.getClass().getName(); builder.append(className); StackTraceFilter filter = new StackTraceFilter(new ClassMethodNameStackTraceSpec(descriptor.getClassName(), null)); List<StackTraceElement> stackTrace = filter.filter(exception); if (stackTrace.size() > 0) { StackTraceElement element = stackTrace.get(0); builder.append(" at "); builder.append(element.getFileName()); builder.append(':'); builder.append(element.getLineNumber()); } builder.append('\n'); if (testLogging.getShowCauses() && exception.getCause() != null) { printException(descriptor, exception.getCause(), true, indentLevel + 1, builder); } }
Example #6
Source File: ShortExceptionFormatter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void printException(TestDescriptor descriptor, Throwable exception, boolean cause, int indentLevel, StringBuilder builder) { String indent = Strings.repeat(INDENT, indentLevel); builder.append(indent); if (cause) { builder.append("Caused by: "); } String className = exception instanceof PlaceholderException ? ((PlaceholderException) exception).getExceptionClassName() : exception.getClass().getName(); builder.append(className); StackTraceFilter filter = new StackTraceFilter(new ClassMethodNameStackTraceSpec(descriptor.getClassName(), null)); List<StackTraceElement> stackTrace = filter.filter(exception); if (stackTrace.size() > 0) { StackTraceElement element = stackTrace.get(0); builder.append(" at "); builder.append(element.getFileName()); builder.append(':'); builder.append(element.getLineNumber()); } builder.append('\n'); if (testLogging.getShowCauses() && exception.getCause() != null) { printException(descriptor, exception.getCause(), true, indentLevel + 1, builder); } }
Example #7
Source File: AbstractTestLogger.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private String getEventPath(TestDescriptor descriptor) { List<String> names = Lists.newArrayList(); TestDescriptor current = descriptor; while (current != null) { if (isAtomicTestWhoseParentIsNotTheTestClass(current)) { // This deals with the fact that in TestNG, there are no class-level events, // but we nevertheless want to see the class name. We use "." rather than // " > " as a separator to make it clear that the class is not a separate // level. This matters when configuring granularity. names.add(current.getClassName() + "." + current.getName()); } else { names.add(current.getName()); } current = current.getParent(); } int effectiveDisplayGranularity = displayGranularity == -1 ? names.size() - 1 : Math.min(displayGranularity, names.size() - 1); List<String> displayedNames = Lists.reverse(names).subList(effectiveDisplayGranularity, names.size()); return Joiner.on(" > ").join(displayedNames) + " "; }
Example #8
Source File: ShortExceptionFormatter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void printException(TestDescriptor descriptor, Throwable exception, boolean cause, int indentLevel, StringBuilder builder) { String indent = Strings.repeat(INDENT, indentLevel); builder.append(indent); if (cause) { builder.append("Caused by: "); } String className = exception instanceof PlaceholderException ? ((PlaceholderException) exception).getExceptionClassName() : exception.getClass().getName(); builder.append(className); StackTraceFilter filter = new StackTraceFilter(new ClassMethodNameStackTraceSpec(descriptor.getClassName(), null)); List<StackTraceElement> stackTrace = filter.filter(exception); if (stackTrace.size() > 0) { StackTraceElement element = stackTrace.get(0); builder.append(" at "); builder.append(element.getFileName()); builder.append(':'); builder.append(element.getLineNumber()); } builder.append('\n'); if (testLogging.getShowCauses() && exception.getCause() != null) { printException(descriptor, exception.getCause(), true, indentLevel + 1, builder); } }
Example #9
Source File: FullExceptionFormatter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Spec<StackTraceElement> createCompositeFilter(TestDescriptor descriptor) { List<Spec<StackTraceElement>> filters = Lists.newArrayList(); for (TestStackTraceFilter type : testLogging.getStackTraceFilters()) { filters.add(createFilter(descriptor, type)); } return new AndSpec<StackTraceElement>(filters); }
Example #10
Source File: TestLogger.java From crate with Apache License 2.0 | 5 votes |
@Override public void afterTest(TestDescriptor test, TestResult result) { if (result.getResultType() == TestResult.ResultType.FAILURE) { LOGGER.error("## FAILURE: " + test); for (String output : testOutputs.getOrDefault(test, List.of())) { System.out.println(output); } for (Throwable exception : result.getExceptions()) { exception.printStackTrace(); } } testOutputs.remove(test); }
Example #11
Source File: StateTrackingTestResultProcessor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private TestDescriptor findDescriptor(Object testId) { TestState state = executing.get(testId); if (state != null) { return state.test; } TestDescriptor d = currentParent; if (d != null) { return d; } //in theory this should not happen return new UnknownTestDescriptor(); }
Example #12
Source File: FullExceptionFormatter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public String format(TestDescriptor descriptor, List<Throwable> exceptions) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < exceptions.size(); i++) { printException(descriptor, exceptions.get(i), null, 0, builder); if (i < exceptions.size() - 1) { builder.append('\n'); } } return builder.toString(); }
Example #13
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 #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: TestCountLogger.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void beforeSuite(TestDescriptor suite) { if (suite.getParent() == null) { progressLogger = factory.newOperation(TestCountLogger.class); progressLogger.setDescription("Run tests"); progressLogger.started(); } }
Example #16
Source File: AbstractTestLogger.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
protected void logEvent(TestDescriptor descriptor, TestLogEvent event, @Nullable String details) { StyledTextOutput output = textOutputFactory.create("TestEventLogger", logLevel); if (!descriptor.equals(lastSeenTestDescriptor) || event != lastSeenTestEvent) { output.println().append(getEventPath(descriptor)); output.withStyle(getStyle(event)).println(event.toString()); } lastSeenTestDescriptor = descriptor; lastSeenTestEvent = event; if (details != null) { output.append(TextUtil.toPlatformLineSeparators(details)); } }
Example #17
Source File: ShortExceptionFormatter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public String format(TestDescriptor descriptor, List<Throwable> exceptions) { StringBuilder builder = new StringBuilder(); for (Throwable exception : exceptions) { printException(descriptor, exception, false, 1, builder); } return builder.toString(); }
Example #18
Source File: FullExceptionFormatter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void printException(TestDescriptor descriptor, Throwable exception, @Nullable List<StackTraceElement> parentTrace, int exceptionLevel, StringBuilder builder) { String exceptionIndent = Strings.repeat(INDENT, exceptionLevel + 1); String exceptionText = exceptionLevel == 0 ? exception.toString() : "\nCaused by:\n" + exception.toString(); String indentedText = TextUtil.indent(exceptionText, exceptionIndent); builder.append(indentedText); builder.append('\n'); String stackTraceIndent = exceptionIndent + INDENT; List<StackTraceElement> stackTrace = null; if (testLogging.getShowStackTraces()) { stackTrace = filterStackTrace(exception, descriptor); int commonElements = countCommonElements(stackTrace, parentTrace); for (int i = 0; i < stackTrace.size() - commonElements; i++) { builder.append(stackTraceIndent); builder.append("at "); builder.append(stackTrace.get(i)); builder.append('\n'); } if (commonElements != 0) { builder.append(stackTraceIndent); builder.append("... "); builder.append(commonElements); builder.append(" more"); builder.append('\n'); } } if (testLogging.getShowCauses() && exception.getCause() != null) { printException(descriptor, exception.getCause(), stackTrace, exceptionLevel + 1, builder); } }
Example #19
Source File: AbstractTestLogger.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
protected void logEvent(TestDescriptor descriptor, TestLogEvent event, @Nullable String details) { StyledTextOutput output = textOutputFactory.create("TestEventLogger", logLevel); if (!descriptor.equals(lastSeenTestDescriptor) || event != lastSeenTestEvent) { output.println().append(getEventPath(descriptor)); output.withStyle(getStyle(event)).println(event.toString()); } lastSeenTestDescriptor = descriptor; lastSeenTestEvent = event; if (details != null) { output.append(TextUtil.toPlatformLineSeparators(details)); } }
Example #20
Source File: ShortExceptionFormatter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public String format(TestDescriptor descriptor, List<Throwable> exceptions) { StringBuilder builder = new StringBuilder(); for (Throwable exception : exceptions) { printException(descriptor, exception, false, 1, builder); } return builder.toString(); }
Example #21
Source File: TestCountLogger.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void beforeSuite(TestDescriptor suite) { if (suite.getParent() == null) { progressLogger = factory.newOperation(TestCountLogger.class); progressLogger.setDescription("Run tests"); progressLogger.started(); } }
Example #22
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 #23
Source File: FullExceptionFormatter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Spec<StackTraceElement> createFilter(TestDescriptor descriptor, TestStackTraceFilter filterType) { switch (filterType) { case ENTRY_POINT: return new ClassMethodNameStackTraceSpec(descriptor.getClassName(), descriptor.getName()); case TRUNCATE: return new TruncatedStackTraceSpec(new ClassMethodNameStackTraceSpec(descriptor.getClassName(), null)); case GROOVY: return new GroovyStackTraceSpec(); default: throw new AssertionError(); } }
Example #24
Source File: FullExceptionFormatter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Spec<StackTraceElement> createCompositeFilter(TestDescriptor descriptor) { List<Spec<StackTraceElement>> filters = Lists.newArrayList(); for (TestStackTraceFilter type : testLogging.getStackTraceFilters()) { filters.add(createFilter(descriptor, type)); } return new AndSpec<StackTraceElement>(filters); }
Example #25
Source File: FullExceptionFormatter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void printException(TestDescriptor descriptor, Throwable exception, @Nullable List<StackTraceElement> parentTrace, int exceptionLevel, StringBuilder builder) { String exceptionIndent = Strings.repeat(INDENT, exceptionLevel + 1); String exceptionText = exceptionLevel == 0 ? exception.toString() : "\nCaused by:\n" + exception.toString(); String indentedText = TextUtil.indent(exceptionText, exceptionIndent); builder.append(indentedText); builder.append('\n'); String stackTraceIndent = exceptionIndent + INDENT; List<StackTraceElement> stackTrace = null; if (testLogging.getShowStackTraces()) { stackTrace = filterStackTrace(exception, descriptor); int commonElements = countCommonElements(stackTrace, parentTrace); for (int i = 0; i < stackTrace.size() - commonElements; i++) { builder.append(stackTraceIndent); builder.append("at "); builder.append(stackTrace.get(i)); builder.append('\n'); } if (commonElements != 0) { builder.append(stackTraceIndent); builder.append("... "); builder.append(commonElements); builder.append(" more"); builder.append('\n'); } } if (testLogging.getShowCauses() && exception.getCause() != null) { printException(descriptor, exception.getCause(), stackTrace, exceptionLevel + 1, builder); } }
Example #26
Source File: FullExceptionFormatter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public String format(TestDescriptor descriptor, List<Throwable> exceptions) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < exceptions.size(); i++) { printException(descriptor, exceptions.get(i), null, 0, builder); if (i < exceptions.size() - 1) { builder.append('\n'); } } return builder.toString(); }
Example #27
Source File: StateTrackingTestResultProcessor.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private TestDescriptor findDescriptor(Object testId) { TestState state = executing.get(testId); if (state != null) { return state.test; } TestDescriptor d = currentParent; if (d != null) { return d; } //in theory this should not happen return new UnknownTestDescriptor(); }
Example #28
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 #29
Source File: TestLogger.java From crate with Apache License 2.0 | 5 votes |
@Override public void onOutput(TestDescriptor test, TestOutputEvent outputEvent) { testOutputs.compute(test, (key, val) -> { if (val == null) { val = new ArrayList<>(); } val.add(outputEvent.getMessage()); return val; }); }
Example #30
Source File: AbstractTestLogger.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
protected void logEvent(TestDescriptor descriptor, TestLogEvent event, @Nullable String details) { StyledTextOutput output = textOutputFactory.create("TestEventLogger", logLevel); if (!descriptor.equals(lastSeenTestDescriptor) || event != lastSeenTestEvent) { output.println().append(getEventPath(descriptor)); output.withStyle(getStyle(event)).println(event.toString()); } lastSeenTestDescriptor = descriptor; lastSeenTestEvent = event; if (details != null) { output.append(TextUtil.toPlatformLineSeparators(details)); } }