Search in sources :

Example 1 with TestFilter

use of org.gradle.api.tasks.testing.TestFilter 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)

Aggregations

Project (org.gradle.api.Project)1 Test (org.gradle.api.tasks.testing.Test)1 TestFilter (org.gradle.api.tasks.testing.TestFilter)1 InternalJvmTestRequest (org.gradle.tooling.internal.protocol.test.InternalJvmTestRequest)1