기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
AWS 디바이스 팜의 사용자 지정 테스트 환경 사용
기본 표준 테스트 환경을 제공하는 것 외에도 AWS Device Farm을 사용하면 자동 테스트를 위한 사용자 지정 환경을 구성할 수 있습니다. 자세한 정보는 테스트 환경을 참조하세요.
YAML 형식의 테스트 사양 (테스트 사양) 파일을 사용하여 사용자 지정 자동 테스트 환경을 설정하고 구성할 수 있습니다. Device Farm은 지원되는 각 테스트 유형에 대한 기본 테스트 사양을 제공합니다. 기존 테스트 사양을 그대로 사용하거나 원하는 경우 편집할 수 있습니다. 테스트 사양 파일을 편집하는 경우 향후 실행을 위해 저장할 수 있습니다.
자세한 정보는 AWS CLI를 사용하여 사용자 지정 테스트 사양 업로드 및 디바이스 팜에서 테스트 실행 생성 단원을 참조하십시오.
테스트 사양 구문
YAML 테스트 사양 파일 구조입니다.
version: 0.1 phases: install: commands: - command - command pre_test: commands: - command - command test: commands: - command - command post_test: commands: - command - command artifacts: - location - location
테스트 사양에는 다음이 포함되어 있습니다.
version
-
디바이스 팜 지원 테스트 사양 버전을 반영합니다. 현재 버전 번호는 0.1입니다.
phases
-
이 섹션에는 테스트 실행 중에 실행되는 명령 그룹이 포함되어 있습니다.
허용되는 테스트 단계 이름은 다음과 같습니다.
install
-
선택 사항.
Device Farm에서 지원하는 테스트 프레임워크의 기본 종속성이 이미 설치되어 있습니다. 이 단계에는 설치 중에 장치 팜이 실행하는 추가 명령 (있는 경우) 이 포함됩니다.
pre_test
-
선택 사항.
자동화된 테스트 실행 전에 실행되는 명령(있는 경우)입니다.
test
-
선택 사항.
자동화된 테스트 실행 중에 실행되는 명령입니다. 테스트 단계에서 명령이 실패할 경우 테스트가 실패로 표시됩니다.
post_test
-
선택 사항.
자동화된 테스트 실행 후에 실행되는 명령입니다.
artifacts
-
선택 사항.
디바이스 팜은 여기에 지정된 위치에서 사용자 지정 보고서, 로그 파일 및 이미지와 같은 아티팩트를 수집합니다. 와일드카드 문자는 아티팩트 위치의 일부로 지원되지 않으므로 각 위치의 올바른 경로를 지정해야 합니다.
이러한 테스트 아티팩트는 테스트 실행에서 각 디바이스에 사용할 수 있습니다. 테스트 아티팩트 검색에 대한 자세한 내용은 사용자 지정 테스트 환경에서 아티팩트 사용을 참조하십시오.
중요
테스트 사양은 올바른 YAML 파일 형식으로 지정해야 합니다. 테스트 사양에서 들여쓰기 또는 공백이 잘못된 경우 테스트 실행이 실패할 수 있습니다. YAML 파일에서 탭은 허용되지 않습니다. YAML 검사기를 사용하여 테스트 사양이 올바른 YAML 파일인지 여부를 테스트할 수 있습니다. 자세한 내용은 YAML 웹 사이트
테스트 사양 예제
다음은 Appium Java TestNG 테스트 실행을 구성하는 디바이스 팜 YAML 테스트 사양의 예입니다.
version: 0.1 # Phases are a 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: # By default, Appium server version used is 1.7.2. # You can switch to an alternate supported version from 1.6.5, 1.7.1, 1.7.2, 1.8.0 or 1.8.1 by using a command like "avm 1.7.1" # OR # To install a newer version of Appium use the following commands: # - export APPIUM_VERSION=1.8.1 # - 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: # Setup environment variables for java - export CLASSPATH=$CLASSPATH:$DEVICEFARM_TESTNG_JAR - export CLASSPATH=$CLASSPATH:$DEVICEFARM_TEST_PACKAGE_PATH/* - export CLASSPATH=$CLASSPATH:$DEVICEFARM_TEST_PACKAGE_PATH/dependency-jars/* # 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 --device-name $DEVICEFARM_DEVICE_NAME --platform-name $DEVICEFARM_DEVICE_PLATFORM_NAME --app $DEVICEFARM_APP_PATH --udid $DEVICEFARM_DEVICE_UDID --chromedriver-executable $DEVICEFARM_CHROMEDRIVER_EXECUTABLE >> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 & - >- start_appium_timeout=0; while [ true ]; do if [ $start_appium_timeout -gt 30 ]; then echo "appium server never started in 30 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 start your test suite execution. test: commands: # Your test package is downloaded in $DEVICEFARM_TEST_PACKAGE_PATH so we first change directory to that path. - echo "Navigate to test package directory" - cd $DEVICEFARM_TEST_PACKAGE_PATH # By default, the following command is used by Device Farm to run your Appium TestNG test. # The goal is to run to your tests jar file with all the dependencies jars in the CLASSPATH. # Alternatively, You may specify your customized command. # Note: For most use cases, the default command works fine. # Please refer "http://testng.org/doc/documentation-main.html#running-testng" for more options on running TestNG tests from the command line. - echo "Start Appium TestNG test" - java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH org.testng.TestNG -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10 # To run your tests with testng.xml file, use the following sequence: # Note: you don't have to unzip your test jar unless you have xml file with custom name # 1. Your testng.xml is inside the test jar after packaging step. Unzip it using commands: # - echo "Unzipping TestNG tests jar" # - unzip *-tests.jar # 2. Run your TestSuite by specifying the unzipped testng.xml using commands: # - echo "Start Appium TestNG test" # - java org.testng.TestNG -d $DEVICEFARM_LOG_DIR/test-output testng.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