Gradle Runner
Executes a Gradle build, allowing inspection of the outcome.
A Gradle runner can be used to functionally test build logic, by executing a contrived build. Assertions can then be made on the outcome of the build, such as the state of files created by the build, or what tasks were actually executed during the build.
A runner can be created via the create method.
Typically, the test code using the runner will programmatically create a build (e.g. by writing Gradle build files to a temporary space) to execute. The build to execute is effectively specified by the withProjectDir} method. It is a requirement that a project directory be set.
The withArguments method allows the build arguments to be specified, just as they would be on the command line.
The build method can be used to invoke the build when it is expected to succeed, while the buildAndFail method can be used when the build is expected to fail.
GradleRunner instances are not thread safe and cannot be used concurrently. However, multiple instances are able to be used concurrently.
On Windows, Gradle runner disables file system watching for the executed build, since the Windows watchers add a file lock on the root project directory, causing problems when trying to delete it. You can still enable file system watching manually for your test by adding the `--watch-fs` command line argument via withArguments.
Please see the Gradle TestKit User Manual chapter for more information.
Since
2.6