Running Appium tests

The following sections describe how to run Appium tests in some of the common frameworks.

Running Tips

Before running your Appium test for Mobile Center, make sure your environment is set up properly and that you have included the required capabilities. For details, see Appium integration.

Consider the following when running Appium tests:

  • When forcibly stopping an Appium test (for example while debugging code), the device will remain locked on the Mobile Center server, only becoming available after several minutes.
  • The kill application extension is not supported in .NET environments.

Refer to the See also section for links to sample code.

Back to top

Run your Appium test in Eclipse

To run your Appium test in Eclipse:

  1. Open your project in Eclipse. Set the Mobile Center Appium Capabilities as needed, including the server and device information.
  2. Launch the test.
  3. View the Eclipse console and ensure that your test is running properly.
  4. View the actions on the device through the Mobile Center console. You will notice that the device becomes locked and reserved by you.

Back to top

Run your Appium test with Apache Ant

To run your Appium test with Ant:

  1. Download and install Apache Ant.
  2. Set the required environment variables.
  3. Open a command dialog box and navigate to your Appium workspace path.
  4. Run the command ant <test_name>.java. Your test run will begin.
  5. View the Ant console and ensure that your test is running.
  6. View the actions on the device through the Mobile Center console. You will notice that the device becomes locked and reserved by you.

Back to top

Run a single job project in Jenkins

To run your Appium test as a Jenkins job: (Terminology refers to Jenkins 2.00 and higher):

  1. Download and install Apache Ant. Set the relevant environment variables.
  2. Open the Jenkins dashboard and click New item.
  3. Specify an Item name and click Freestyle project.
  4. In the General tab, click Advanced.
  5. Select Use custom workspace and enter your Appium workspace path.
  6. In the Build section, select Invoke ant.
  7. Click the Advanced button. Provide a target name and the full path to the build.xml file in the Build File field.
  8. Click Save.
  9. On the project page, click Build Now.
  10. View the actions on the device through the Mobile Center console. You will notice that the device becomes locked and reserved by you.
  11. Inside the Build History list, click on the build number. In the pane that opens, click Console Output to view the test execution log in the Jenkins console.

Back to top

Run a MultiJob project in Jenkins

To run multiple Appium tests as a Jenkins job: (Terminology refers to Jenkins 2.00 and higher):

  1. Prepare several single job freestyle jobs, as described above.
  2. Click New item and specify a MultiJob project. Click OK.
  3. In the Build section, select MultiJob Phase from the Add build step drop-down. Enter a phase name.
  4. Click Add jobs and select the first job you want to add. Repeat this step for all of the jobs you want to include in this phase.
  5. Select an option from the Job execution type drop-down: sequentially or in parallel. If you are executing multiple jobs, but only have one device, the jobs will be executed sequentially—not in parallel.

  6. Optionally, select a continuation condition, for example: Always, Successful, or Completed.
  7. Click Save.
  8. On the project page, click Build Now.
  9. View the actions on the device(s) through the Mobile Center console. You will notice that the devices become locked and reserved by you.
  10. Inside the Build History list, click on the build number. In the pane that opens, click Console Output to view the test execution log in the Jenkins console.

Tip: The udid, name, and platformVersion capabilities are optional. You can use the platformName capability alone, to instruct the Appium test to look for the next available device.

Back to top

See also: