withTestsFor

Adds tests to be executed declared using a fine-grained test selection API.

Clients can target tests via the TestSpec interface, which can configure the target test tasks as well as what tests should be executed

    TestLauncher testLauncher = projectConnection.newTestLauncher();
    testLauncher.withTestsFor(spec -> {
        spec.forTaskPath(":test")
            .includePackage("org.pkg")
            .includeClass("com.TestClass")
            .includeMethod("com.TestClass")
            .includePattern("io.*")
    }).run();

Note: These tests are ignored for target Gradle version earlier than 7.6.

Return

this

Since

7.6

Parameters

testSpec

The action selecting the target tests.