@Override public void started(final TestDescriptorInternal test, TestStartEvent event) { processor.started(test, event); outputRedirector.setOutputOwner(test.getId()); if (rootId == null) { outputRedirector.startRedirecting(); rootId = test.getId(); } else { Object parentId = event.getParentId(); if (parentId == null) { //if we don't know the parent we will use the top suite //this way we always have and id to attach logging events for parentId = rootId; } parents.put(test.getId(), parentId); } }
@Override public void started(TestDescriptorInternal test, TestStartEvent startEvent) { if (test.isComposite()) { testListener.beforeSuite(test); } else { testListener.beforeTest(test); } }
@Override public void completed(TestDescriptorInternal test, TestResult result, TestCompleteEvent completeEvent) { if (test.isComposite()) { testListener.afterSuite(test, result); } else { testListener.afterTest(test, result); } }
private DefaultTestDescriptor toTestDescriptorForSuite(TestDescriptorInternal suite) { Object id = suite.getId(); String name = suite.getName(); String displayName = suite.toString(); String testKind = InternalJvmTestDescriptor.KIND_SUITE; String suiteName = suite.getName(); String className = suite.getClassName(); String methodName = null; Object parentId = getParentId(suite); final String testTaskPath = getTaskPath(suite); return new DefaultTestDescriptor(id, name, displayName, testKind, suiteName, className, methodName, parentId, testTaskPath); }
private DefaultTestDescriptor toTestDescriptorForTest(TestDescriptorInternal test) { Object id = test.getId(); String name = test.getName(); String displayName = test.toString(); String testKind = InternalJvmTestDescriptor.KIND_ATOMIC; String suiteName = null; String className = test.getClassName(); String methodName = test.getName(); Object parentId = getParentId(test); final String taskPath = getTaskPath(test); return new DefaultTestDescriptor(id, name, displayName, testKind, suiteName, className, methodName, parentId, taskPath); }
private String getTaskPath(TestDescriptorInternal givenDescriptor) { TestDescriptorInternal descriptor = givenDescriptor; while (descriptor.getOwnerBuildOperationId() == null && descriptor.getParent() != null) { descriptor = descriptor.getParent(); } return runningTasks.get(descriptor.getOwnerBuildOperationId()); }
private Object getParentId(TestDescriptorInternal descriptor) { TestDescriptorInternal parent = descriptor.getParent(); if (parent != null) { return parent.getId(); } // only set the TaskOperation as the parent if the Tooling API Consumer is listening to task progress events if (clientSubscriptions.isSendTaskProgressEvents()) { return descriptor.getOwnerBuildOperationId(); } return null; }
@Override public void completed(TestDescriptorInternal testDescriptor, TestResult testResult, TestCompleteEvent completeEvent) { if (testDescriptor.getParent() == null) { resultCount = resultCount + testResult.getTestCount(); } if (!testDescriptor.isComposite() && testResult.getFailedTestCount() != 0) { failedTests.add(new FailedTest(testDescriptor.getName(), testDescriptor.getClassName(), getTaskPath(testDescriptor))); } }
private String getTaskPath(TestDescriptorInternal givenDescriptor) { TestDescriptorInternal descriptor = givenDescriptor; while (descriptor.getOwnerBuildOperationId() == null && descriptor.getParent() != null) { descriptor = descriptor.getParent(); } String taskPath = runningTasks.get(descriptor.getOwnerBuildOperationId()); if (taskPath == null) { throw new IllegalStateException("No parent task for test " + givenDescriptor); } return taskPath; }
private static DefaultTestClassDescriptor testClass(String id, String className, final TestDescriptorInternal parent) { return new DefaultTestClassDescriptor(id, className){ private static final long serialVersionUID = 1L; @Override public TestDescriptorInternal getParent() { return parent; } }; }
private static DefaultTestMethodDescriptor testMethod(String id, String className, String methodName, final TestDescriptorInternal parent) { return new DefaultTestMethodDescriptor(id, className, methodName) { private static final long serialVersionUID = 1L; @Override public TestDescriptorInternal getParent() { return parent; } }; }
@Override protected void started(TestState state) { TestDescriptorInternal test = state.test; if (test.isComposite()) { testListener.beforeSuite(test); } else { testListener.beforeTest(test); } }
@Override protected void completed(TestState state) { TestResult result = new DefaultTestResult(state); TestDescriptorInternal test = state.test; if (test.isComposite()) { testListener.afterSuite(test, result); } else { testListener.afterTest(test, result); } }
@Override public TestDescriptorInternal getParent() { return null; }
@Override public void output(TestDescriptorInternal test, TestOutputEvent event) { testOutputListener.onOutput(test, event); }
public TestState(TestDescriptorInternal test, TestStartEvent startEvent, Map<Object, TestState> executing) { this.test = test; this.startEvent = startEvent; this.executing = executing; }
@Override public void started(TestDescriptorInternal testDescriptor, TestStartEvent startEvent) { eventConsumer.dispatch(new DefaultTestStartedProgressEvent(startEvent.getStartTime(), adapt(testDescriptor))); }
@Override public void completed(TestDescriptorInternal testDescriptor, TestResult testResult, TestCompleteEvent completeEvent) { eventConsumer.dispatch(new DefaultTestFinishedProgressEvent(completeEvent.getEndTime(), adapt(testDescriptor), adapt(testResult))); }
@Override public void output(TestDescriptorInternal testDescriptor, TestOutputEvent event) { // Don't forward }
private DefaultTestDescriptor adapt(TestDescriptorInternal testDescriptor) { return testDescriptor.isComposite() ? toTestDescriptorForSuite(testDescriptor) : toTestDescriptorForTest(testDescriptor); }
@Override public void output(TestDescriptorInternal testDescriptor, TestOutputEvent event) { }
@Override public void started(TestDescriptorInternal testDescriptorInternal, TestStartEvent testStartEvent) { }
private static TestStartEvent startEvent(TestDescriptorInternal parent) { return new TestStartEvent(System.currentTimeMillis(), parent.getId()); }
@Override public TestDescriptorInternal getParent() { return parent; }
@Override public void started(TestDescriptorInternal testDescriptor, TestStartEvent startEvent) { }
void started(TestDescriptorInternal testDescriptor, TestStartEvent startEvent);
void completed(TestDescriptorInternal testDescriptor, TestResult testResult, TestCompleteEvent completeEvent);
void output(TestDescriptorInternal testDescriptor, TestOutputEvent event);