use of org.gradle.tooling.internal.protocol.events.InternalTestDescriptor in project gradle by gradle.
the class TestExecutionBuildConfigurationAction method configureBuildForTestDescriptors.
private List<Test> configureBuildForTestDescriptors(GradleInternal gradle, TestExecutionRequestAction testExecutionRequest) {
final Collection<InternalTestDescriptor> testDescriptors = testExecutionRequest.getTestExecutionDescriptors();
final List<String> testTaskPaths = org.gradle.util.CollectionUtils.collect(testDescriptors, new Transformer<String, InternalTestDescriptor>() {
@Override
public String transform(InternalTestDescriptor testDescriptor) {
return ((DefaultTestDescriptor) testDescriptor).getTaskPath();
}
});
List<Test> testTasksToRun = new ArrayList<Test>();
for (final String testTaskPath : testTaskPaths) {
final Task task = gradle.getRootProject().getTasks().findByPath(testTaskPath);
if (task == null) {
throw new TestExecutionException(String.format("Requested test task with path '%s' cannot be found.", testTaskPath));
} else if (!(task instanceof Test)) {
throw new TestExecutionException(String.format("Task '%s' of type '%s' not supported for executing tests via TestLauncher API.", testTaskPath, task.getClass().getName()));
} else {
Test testTask = (Test) task;
for (InternalTestDescriptor testDescriptor : testDescriptors) {
DefaultTestDescriptor defaultTestDescriptor = (DefaultTestDescriptor) testDescriptor;
if (defaultTestDescriptor.getTaskPath().equals(testTaskPath)) {
String className = defaultTestDescriptor.getClassName();
String methodName = defaultTestDescriptor.getMethodName();
if (className == null && methodName == null) {
testTask.getFilter().includeTestsMatching("*");
} else {
testTask.getFilter().includeTest(className, methodName);
}
}
}
testTasksToRun.add(testTask);
}
}
return testTasksToRun;
}
use of org.gradle.tooling.internal.protocol.events.InternalTestDescriptor in project gradle by gradle.
the class TestExecutionResultEvaluator method formatInternalTestExecutionRequest.
private String formatInternalTestExecutionRequest() {
StringBuilder requestDetails = new StringBuilder(INDENT).append("Requested tests:");
for (InternalTestDescriptor internalTestDescriptor : internalTestExecutionRequest.getTestExecutionDescriptors()) {
requestDetails.append("\n").append(Strings.repeat(INDENT, 2)).append(internalTestDescriptor.getDisplayName());
requestDetails.append(" (Task: '").append(((DefaultTestDescriptor) internalTestDescriptor).getTaskPath()).append("')");
}
final Collection<InternalJvmTestRequest> internalJvmTestRequests = internalTestExecutionRequest.getInternalJvmTestRequests();
for (InternalJvmTestRequest internalJvmTestRequest : internalJvmTestRequests) {
final String className = internalJvmTestRequest.getClassName();
final String methodName = internalJvmTestRequest.getMethodName();
if (methodName == null) {
requestDetails.append("\n").append(Strings.repeat(INDENT, 2)).append("Test class ").append(className);
} else {
requestDetails.append("\n").append(Strings.repeat(INDENT, 2)).append("Test method ").append(className).append(".").append(methodName).append("()");
}
}
return requestDetails.toString();
}
Aggregations