Use the following instructions to integrate Appium tests with AWS Device Farm. For more information about using Appium tests in Device Farm, see Appium tests and AWS Device Farm.
Configure your Appium test package
Use the following instructions to configure your test package.
-
Modify
pom.xml
to set packaging to a JAR file:<groupId>com.acme</groupId> <artifactId>acme-myApp-appium</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging>
-
Modify
pom.xml
to usemaven-jar-plugin
to build your tests into a JAR file.The following plugin builds your test source code (anything in the
src/test
directory) into a JAR file:<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> </executions> </plugin>
-
Modify
pom.xml
to usemaven-dependency-plugin
to build dependencies as JAR files.The following plugin copies your dependencies into the
dependency-jars
directory:<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory> </configuration> </execution> </executions> </plugin>
-
Save the following XML assembly to
src/main/assembly/zip.xml
.The following XML is an assembly definition that, when configured, instructs Maven to build a .zip file that contains everything in the root of your build output directory and the
dependency-jars
directory:<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> <id>zip</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <fileSet> <directory>${project.build.directory}</directory> <outputDirectory>./</outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> <fileSet> <directory>${project.build.directory}</directory> <outputDirectory>./</outputDirectory> <includes> <include>/dependency-jars/</include> </includes> </fileSet> </fileSets> </assembly>
-
Modify
pom.xml
to usemaven-assembly-plugin
to package tests and all dependencies into a single .zip file.The following plugin uses the preceding assembly to create a .zip file named
zip-with-dependencies
in the build output directory every time mvn package is run:<plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.5.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <finalName>zip-with-dependencies</finalName> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>src/main/assembly/zip.xml</descriptor> </descriptors> </configuration> </execution> </executions> </plugin>
Note
If you receive an error that says annotation is not supported in 1.3, add the following to
pom.xml
:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Create a zipped test package file
Warning
In Device Farm, the folder structure of files in your zipped test package matters, and some archival tools will change the structure of your ZIP file implicitly. We recommend that you follow the specified command-line utilities below rather than use the archival utilities built into the file manager of your local desktop (such as Finder or Windows Explorer).
Now, bundle your tests for Device Farm.
Build and package your tests:
$ mvn clean package -DskipTests=true
The file zip-with-dependencies.zip
will be created as a result. This is your test
package.
Upload your test package to Device Farm
You can use the Device Farm console to upload your tests.
Sign in to the Device Farm console at https://console.aws.amazon.com/devicefarm
. -
On the Device Farm navigation panel, choose Mobile Device Testing, then choose Projects.
-
If you are a new user, choose New project, enter a name for the project, then choose Submit.
If you already have a project, you can choose it to upload your tests to it.
-
Open your project, and then choose Create a new run.
-
- For native Android and iOS tests
-
On the Choose application page, choose Mobile App, then select Choose File to upload your application's distributable package.
Note
The file must be either an Android
.apk
or an iOS.ipa
. iOS Applications must be built for real devices, not the Simulator. - For Mobile Web application tests
-
On the Choose application page, choose Web App.
-
Give your test an appropriate name. This may contain any combination of spaces or punctuation.
-
Choose Next.
-
On the Configure page, in the Setup test framework section, choose Appium
language
, then Choose File. -
Browse to and choose the .zip file that contains your tests. The .zip file must follow the format described in Configure your Appium test package.
-
Choose Run your test in a custom environment. This execution environment allows for full control over test setup, teardown, and invocation, as well as choosing specific versions of runtimes and the Appium server. You can configure your custom environment via the test spec file. For more information, see Working with custom test environments in AWS Device Farm.
-
Choose Next, and then follow the instructions to select devices and start the run. For more information, see Creating a test run in Device Farm.
Note
Device Farm does not modify Appium tests.
Take screenshots of your tests (Optional)
You can take screenshots as part of your tests.
Device Farm sets the DEVICEFARM_SCREENSHOT_PATH
property to a fully qualified path on the local
file system where Device Farm expects Appium screenshots to be saved. The test-specific directory where the
screenshots are stored is defined at runtime. The screenshots are pulled into your Device Farm reports
automatically. To view the screenshots, in the Device Farm console, choose the Screenshots section.
For more information on taking screenshots in Appium tests, see Take Screenshot