Skip to content

Commit

Permalink
test with new test spec with appium
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Jul 10, 2024
1 parent 8956c55 commit 3b3be08
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ jobs:
--device_pool_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/iOSPoolArn" --query "SecretString" | cut -f2 -d\") \
--app_file_path ./output/MqttClient.ipa \
--test_file_path ./workspace/test_bundle.zip \
--test_spec_file_path ./DeviceFarmScript/test_spec.yaml
--test_spec_file_path ./DeviceFarmScript/test_spec.yml
devices:
runs-on: ${{ matrix.runner }}
Expand Down
30 changes: 0 additions & 30 deletions Test/IntegrationTests/MqttClient/DeviceFarmScript/test_spec.yaml

This file was deleted.

65 changes: 65 additions & 0 deletions Test/IntegrationTests/MqttClient/DeviceFarmScript/test_spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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:
# To install a newer version of Appium such as version 2.1.2. Appium used to run iOS running script
- export APPIUM_VERSION=2.1.2
- avm $APPIUM_VERSION

# The pre-test phase includes commands that setup your test environment.
pre_test:
commands:
# Appium downloads Chromedriver using a feature that is considered insecure for multitenant
# environments. This is not a problem for Device Farm because each test host is allocated
# exclusively for one customer, then terminated entirely. For more information, please see
# https://github.com/appium/appium/blob/master/packages/appium/docs/en/guides/security.md

# We recommend starting the Appium server process in the background using the command below.
# The Appium server log will be written to the $DEVICEFARM_LOG_DIR directory.
# The environment variables passed as capabilities to the server will be automatically assigned
# during your test run based on your test's specific device.
# For more information about which environment variables are set and how they're set, please see
# https://docs.aws.amazon.com/devicefarm/latest/developerguide/custom-test-environment-variables.html
- |-
appium --base-path=$APPIUM_BASE_PATH --log-timestamp \
--log-no-colors --relaxed-security --default-capabilities \
"{\"appium:deviceName\": \"$DEVICEFARM_DEVICE_NAME\", \
\"platformName\": \"$DEVICEFARM_DEVICE_PLATFORM_NAME\", \
\"appium:app\": \"$DEVICEFARM_APP_PATH\", \
\"appium:udid\":\"$DEVICEFARM_DEVICE_UDID\", \
\"appium:platformVersion\": \"$DEVICEFARM_DEVICE_OS_VERSION\", \
\"appium:chromedriverExecutableDir\": \"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE_DIR\", \
\"appium:automationName\": \"UiAutomator2\"}" \
>> $DEVICEFARM_LOG_DIR/appium.log 2>&1 &
# This code will wait until the Appium server starts.
- |-
appium_initialization_time=0;
until curl --silent --fail "http://0.0.0.0:4723${APPIUM_BASE_PATH}/status"; do
if [[ $appium_initialization_time -gt 30 ]]; then
echo "Appium did not start within 30 seconds. Exiting...";
exit 1;
fi;
appium_initialization_time=$((appium_initialization_time + 1));
echo "Waiting for Appium to start on port 4723...";
sleep 1;
done;
# The test phase includes commands that run your test suite execution.
test:
commands:

# 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

0 comments on commit 3b3be08

Please sign in to comment.