I want to understand more about ConnectedAndroidTest Gradle task. I see that it is used to install the application and test apks and run the tests.
But what are the individual steps that it does? (gradle tasks if any)
"gradle build" seems to generate the Application apk. What task generates the test apk? And how does it(ConnectedAndroidTest) install the application and test apk? And how does it start the tests?
Thanks very much.
The work that Gradle can do on a project is defined by one or more tasks. A task represents some atomic piece of work which a build performs. This might be compiling some classes, creating a JAR, generating Javadoc, or publishing some archives to a repository.
To see which tasks are available for our build we can run Gradle with the command-line option -t or --tasks. Gradle outputs the available tasks from our build script. By default only the tasks which are dependencies on other tasks are shown. To see all tasks we must add the command-line option --all.
Gradle executes tests in a separate ('forked') JVM, isolated from the main build process. This prevents classpath pollution and excessive memory consumption for the build process. It also allows you to run the tests with different JVM arguments than the build is using.
To answer the more general question "what are the list of tasks that task <taskName>
executes?", there are two simple ways to find that out for any given task.
The first is:
./gradlew tasks --all | grep <taskName>
where <taskName>
should be replaced with whatever task you care about. E.g., ./gradlew tasks --all | grep connectedDebugAndroidTest
. Note that I'm piping through grep
to save myself the trouble of manually sifting through the list of all tasks.
The second is:
Use the task-tree plugin. Once applied, usage looks like this:
./gradlew <taskName> taskTree
Or, as I usually prefer it:
./gradlew <taskName> taskTree --no-repeat -quiet
The latter option makes the output a bit less cluttered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With