Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.appium:appium-uiautomator2-server:'
}
dependencies {
implementation("com.github.appium:appium-uiautomator2-server:")
}
<dependency>
<groupId>com.github.appium</groupId>
<artifactId>appium-uiautomator2-server</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.appium" % "appium-uiautomator2-server" % ""
:dependencies [[com.github.appium/appium-uiautomator2-server ""]]
A netty server that runs on the device listening for commands and executes using UiAutomator V2.
build the android project using below commands
./gradlew clean assembleServerDebug assembleServerDebugAndroidTest
You can also build with specific version name and version code using this command.
./gradlew -PversionName=8.0.0 -PversionCode=300 clean assembleServerDebug assembleServerDebugAndroidTest
push both src and test apks to the device and execute the instrumentation tests.
adb shell am instrument -w io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner
build the unitTest flavor using the below commands
./gradlew clean assembleE2ETestDebug assembleE2ETestDebugAndroidTest
unitTest flavor contains tests for handlers and can be invoked by using following command
./gradlew clean connectedE2ETestDebugAndroidTest
the above command takes care about installing the AUT apk in to the testing device/emulator before running the tests.
you can also invoke the test using below command
adb shell am instrument -w io.appium.uiautomator2.e2etest.test/androidx.test.runner.AndroidJUnitRunner
Note: AUT apk should be installed before executing above command.