Search in sources :

Example 1 with TaskSelectionException

use of org.gradle.execution.TaskSelectionException in project gradle by gradle.

the class TestExecutionBuildConfigurationAction method queryTestTasks.

private Set<Test> queryTestTasks(String testTaskPath) {
    TaskSelection taskSelection;
    try {
        taskSelection = taskSelector.getSelection(testTaskPath);
    } catch (TaskSelectionException e) {
        throw new TestExecutionException(String.format("Requested test task with path '%s' cannot be found.", testTaskPath));
    }
    Set<Task> tasks = taskSelection.getTasks();
    if (tasks.isEmpty()) {
        throw new TestExecutionException(String.format("Requested test task with path '%s' cannot be found.", testTaskPath));
    }
    Set<Test> result = new LinkedHashSet<>();
    for (Task task : tasks) {
        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()));
        }
        result.add((Test) task);
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TaskSelection(org.gradle.execution.TaskSelection) Task(org.gradle.api.Task) TestExecutionException(org.gradle.api.tasks.testing.TestExecutionException) Test(org.gradle.api.tasks.testing.Test) TaskSelectionException(org.gradle.execution.TaskSelectionException)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 Task (org.gradle.api.Task)1 Test (org.gradle.api.tasks.testing.Test)1 TestExecutionException (org.gradle.api.tasks.testing.TestExecutionException)1 TaskSelection (org.gradle.execution.TaskSelection)1 TaskSelectionException (org.gradle.execution.TaskSelectionException)1