How to print test commandline before execution?

I’m migrating our system from Ant to Gradle. Ant’s TestNG plugin has a dumpCommand option, which prints the command that starts the test execution.

I found this old post, but it seems to be exclusive to the Exec command: How do I easily print commands being run by Exec tasks?

I tried doing this, but it gets null for both the executable as well as the result of the forEach loop (which causes an exception on .join()). I’m not sure jvmArgumentProviders is even the right thing, as the only provider in there appears related to JaCoCo.

test {
    useTestNG()
    ...
    doFirst {
        println executable + jvmArgumentProviders.forEach{ provider -> provider.asArguments() }.join()
        ...
    }
...
}

In case it is relevant, the test task is not called directly. Here’s an example of one of my tasks to execute tests:

tasks.register('testng-run-local') {
    finalizedBy test
    doFirst {
        test.ext.'testng-xml' = 'src/testng.xml'
        ...
        test.ext.'isLocal' = 'true'
    }
}

Thanks!