Search in sources :

Example 1 with NoMatchingTestsReporter

use of org.gradle.api.internal.tasks.testing.NoMatchingTestsReporter in project gradle by gradle.

the class JavaBasePlugin method configureBasedOnSingleProperty.

private void configureBasedOnSingleProperty(final Test test) {
    String singleTest = getTaskPrefixedProperty(test, "single");
    if (singleTest == null) {
        // configure inputs so that the test task is skipped when there are no source files.
        // unfortunately, this only applies when 'test.single' is *not* applied
        // We should fix this distinction, the behavior with 'test.single' or without it should be the same
        test.getInputs().files(test.getCandidateClassFiles()).withPropertyName("nonEmptyCandidateClassFiles").withPathSensitivity(PathSensitivity.RELATIVE).skipWhenEmpty();
        return;
    }
    test.prependParallelSafeAction(new Action<Task>() {

        public void execute(Task task) {
            test.getLogger().info("Running single tests with pattern: {}", test.getIncludes());
        }
    });
    test.setIncludes(WrapUtil.toSet("**/" + singleTest + "*.class"));
    test.addTestListener(new NoMatchingTestsReporter("Could not find matching test for pattern: " + singleTest));
}
Also used : Task(org.gradle.api.Task) DefaultTask(org.gradle.api.DefaultTask) NoMatchingTestsReporter(org.gradle.api.internal.tasks.testing.NoMatchingTestsReporter)

Aggregations

DefaultTask (org.gradle.api.DefaultTask)1 Task (org.gradle.api.Task)1 NoMatchingTestsReporter (org.gradle.api.internal.tasks.testing.NoMatchingTestsReporter)1