Search in sources :

Example 1 with InternalJvmTestRequest

use of org.gradle.tooling.internal.protocol.test.InternalJvmTestRequest in project gradle by gradle.

the class TestExecutionBuildConfigurationAction method configureBuildForInternalJvmTestRequest.

private List<Test> configureBuildForInternalJvmTestRequest(GradleInternal gradle, TestExecutionRequestAction testExecutionRequest) {
    final Collection<InternalJvmTestRequest> internalJvmTestRequests = testExecutionRequest.getInternalJvmTestRequests();
    if (internalJvmTestRequests.isEmpty()) {
        return Collections.emptyList();
    }
    List<Test> tasksToExecute = new ArrayList<Test>();
    final Set<Project> allprojects = gradle.getRootProject().getAllprojects();
    for (Project project : allprojects) {
        final Collection<Test> testTasks = project.getTasks().withType(Test.class);
        for (Test testTask : testTasks) {
            for (InternalJvmTestRequest jvmTestRequest : internalJvmTestRequests) {
                final TestFilter filter = testTask.getFilter();
                filter.includeTest(jvmTestRequest.getClassName(), jvmTestRequest.getMethodName());
            }
        }
        tasksToExecute.addAll(testTasks);
    }
    return tasksToExecute;
}
Also used : Project(org.gradle.api.Project) InternalJvmTestRequest(org.gradle.tooling.internal.protocol.test.InternalJvmTestRequest) Test(org.gradle.api.tasks.testing.Test) TestFilter(org.gradle.api.tasks.testing.TestFilter)

Example 2 with InternalJvmTestRequest

use of org.gradle.tooling.internal.protocol.test.InternalJvmTestRequest 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();
}
Also used : InternalJvmTestRequest(org.gradle.tooling.internal.protocol.test.InternalJvmTestRequest) DefaultTestDescriptor(org.gradle.tooling.internal.provider.events.DefaultTestDescriptor) InternalTestDescriptor(org.gradle.tooling.internal.protocol.events.InternalTestDescriptor)

Aggregations

InternalJvmTestRequest (org.gradle.tooling.internal.protocol.test.InternalJvmTestRequest)2 Project (org.gradle.api.Project)1 Test (org.gradle.api.tasks.testing.Test)1 TestFilter (org.gradle.api.tasks.testing.TestFilter)1 InternalTestDescriptor (org.gradle.tooling.internal.protocol.events.InternalTestDescriptor)1 DefaultTestDescriptor (org.gradle.tooling.internal.provider.events.DefaultTestDescriptor)1