Apptim runs tests in AWS Device Farm using a custom test environment.

You can set up and configure your custom automated test environment with a YAML-formatted test specification (Test Spec) file. A Test Spec has basically four main phases that can be override / modified as needed using bash commands. These phases are listed below:

  1. Install: Typically to set up any requirement or assets to run the tests.
  2. Pre-test: When apptim and appium are launched.
  3. Run-test: Where test file is unzipped and tests are launched using the command line.
  4. Post-test: Typically to execute custom actions after the test ends.

Each test runner has its own scripts that can be modified by the user in order to run custom actions for each platform (Android or iOS) in AWS Device Farm. For example:

Untitled

This is how the complete spec file template looks like:

# Phases are collection of commands that get executed on Device Farm.
phases:
  install:
    commands:
{{apptim_install_phase}}
{{user_install_steps}}

  # The pre-test phase includes commands that setup your test environment.
  pre_test:
    commands:
{{user_pre_test}}
{{apptim_launch_agent}}

  # The test phase includes commands that start your test suite execution.
  test:
    commands:
{{apptim_start_test}}
{{user_run_test}}

  # The post test phase includes commands that are run after your tests are executed.
  post_test:
    commands:
{{apptim_stop_test}}
{{user_post_test}}

You can run custom bash steps on AWS Device Farm by modifying the {{user_???}} in any phase, using the YAML files located in your apptim-cli installation folder. You can navigate to these YAML files by going to the ./templates/ inside your apptim-cli installation folder depending on your test-runner. For example for android nodeJS runner, open the scripts at ./templates/nodejs/android/

<aside> ⚠️ It is important to respect YAML spacing to avoid issues on merge, all steps needs to start with 6 whitespaces.

</aside>


Modifying default command to run tests

TestNG files can be run using different mechanisms. The default mechanism is to navigate to the test folder and run it using java, as show below:

      - cd $DEVICEFARM_TEST_PACKAGE_PATH
      - java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH org.testng.TestNG -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10

You can change this mechanism, by modifying the ./templates/testng/{platform}/user-run-test-steps.yml spec file.

On NodeJS, ****there is a way to just change the command to run on the test runner itself. Please check Working with Appium NodeJS documentation.