version: 0.1 # Phases are collection of commands that get executed on Device Farm. phases: # The install phase includes commands that install dependencies that your tests use. # Default dependencies for testing frameworks supported on Device Farm are already installed. install: commands: # Device Farm support two major versions of Python, each with one minor version: 2 (minor version 2.7), and 3 (minor version 3.7.4). # The default Python version is 2, but you can switch to 3 by setting the following variable to 3: - export PYTHON_VERSION=3 # This command will install your dependencies and verify that they're using the proper versions that you specified in your requirements.txt file. Because Device Farm preconfigures your environment within a # Python Virtual Environment in its setup phase, you can use pip to install any Python packages just as you would locally. - cd $DEVICEFARM_TEST_PACKAGE_PATH - . bin/activate - pip install -r requirements.txt # This test execution environment uses Appium version 1.9.1 by default, however we enable you to change it using the Appium version manager (avm). An # example "avm" command below changes the version to 1.14.2. # For your convenience, we have preinstalled the following versions: 1.9.1, 1.10.1, 1.11.1, 1.12.1, 1.13.0, 1.14.1, 1.14.2, 1.15.1 or 1.16.0. # To use one of these Appium versions, change the version number in the "avm" command below to your desired version: - export APPIUM_VERSION=1.14.2 - avm $APPIUM_VERSION - ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium /usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js # The pre-test phase includes commands that setup your test environment. pre_test: commands: # We recommend starting appium server process in the background using the command below. # Appium server log will go to $DEVICEFARM_LOG_DIR directory. # The environment variables below will be auto-populated during run time. - echo "Start appium server" - >- appium --log-timestamp --default-capabilities "{\"deviceName\": \"$DEVICEFARM_DEVICE_NAME\", \"platformName\":\"$DEVICEFARM_DEVICE_PLATFORM_NAME\", \"app\":\"$DEVICEFARM_APP_PATH\", \"udid\":\"$DEVICEFARM_DEVICE_UDID\", \"platformVersion\":\"$DEVICEFARM_DEVICE_OS_VERSION\", \"chromedriverExecutable\":\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE\"}" >> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 & - >- start_appium_timeout=0; while [ true ]; do if [ $start_appium_timeout -gt 60 ]; then echo "appium server never started in 60 seconds. Exiting"; exit 1; fi; grep -i "Appium REST http interface listener started on 0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1; if [ $? -eq 0 ]; then echo "Appium REST http interface listener started on 0.0.0.0:4723"; break; else echo "Waiting for appium server to start. Sleeping for 1 second"; sleep 1; start_appium_timeout=$((start_appium_timeout+1)); fi; done; # The test phase includes commands that run your test suite execution. test: commands: # Your test package is downloaded in $DEVICEFARM_TEST_PACKAGE_PATH so we first change directory to that path. # We already setup python virtual environment on $DEVICEFARM_TEST_PACKAGE_PATH # and installed required libraries. You can run your test under $DEVICEFARM_TEST_PACKAGE_PATH - echo "Navigate to test package directory" - cd $DEVICEFARM_TEST_PACKAGE_PATH - echo "Start Appium Python test" - adb forward tcp:13000 tcp:13000 # By default, the following command is used by Device Farm to run your Appium Python test. # The goal is to run all your tests files in the test package. # Alternatively, You may specify your customized command. # Note: For most use cases, the default command works fine. # Please refer "https://docs.pytest.org/en/latest/usage.html" for more options on running pytests from command line. - py.test tests/ --junit-xml $DEVICEFARM_LOG_DIR/junitreport.xml # The post test phase includes are commands that are run after your tests are executed. post_test: commands: # The artifacts phase lets you specify the location where your tests logs, device logs will be stored. # And also let you specify the location of your test logs and artifacts which you want to be collected by Device Farm. # These logs and artifacts will be available through ListArtifacts API in Device Farm. artifacts: # By default, Device Farm will collect your artifacts from following directories - $DEVICEFARM_LOG_DIR