atest로 플랫폼 코드 테스트
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
플랫폼용 Android 스튜디오 (ASfP)는 atest
명령줄 도구와 통합되어 연결된 기기나 에뮬레이터에서 IDE를 통해 직접 테스트를 실행할 수 있습니다.
기본 요건
- AOSP 소스 코드로 ASfP 프로젝트를 엽니다.
- 코드를 빌드하고 기기 또는 에뮬레이터에 플래시합니다.
source build/envsetup.sh
및 lunch
을 사용하여 빌드 환경을 초기화합니다.
테스트 실행
다음과 같은 여러 방법으로 ASfP에서 atest
를 사용하여 테스트를 실행할 수 있습니다.
여백 실행 아이콘: 실행 아이콘 play_circle을 클릭합니다.
테스트 클래스 또는 메서드 옆에 있는 아이콘을 클릭하여 해당 테스트를 실행합니다.
마우스 오른쪽 버튼 클릭 메뉴: 프로젝트 창 또는 편집기에서 테스트 파일, 클래스 또는 메서드를 마우스 오른쪽 버튼으로 클릭하고 Run 'atest'를 선택합니다.
터미널 사용: ASfP (보기 > 도구 창 > 터미널)에서 통합 터미널을 열고 atest
명령어를 직접 실행합니다. 예: bash
atest MyTestModule
atest MyTestClass#myTestMethod
테스트 결과 보기
테스트 결과는 ASfP 내의 Run 도구 창에 표시됩니다. 이 창에는 테스트 진행 상황, 통과 또는 실패 상태가 표시되며 각 테스트의 로그와 출력이 제공됩니다.
테스트 구성
거터 또는 마우스 오른쪽 버튼 클릭 메뉴에서 테스트를 실행하면 ASfP가 임시 실행 또는 디버그 구성을 자동으로 만듭니다. 이러한 구성을 수정하고 저장하여 특정 옵션이나 플래그로 테스트를 빠르게 다시 실행할 수 있습니다.
- Run > Edit Configurations로 이동합니다.
- 수정하려는
atest
구성을 찾거나 + 버튼을 클릭하고 atest를 선택하여 새 구성을 만듭니다.
- 테스트 모듈, 클래스, 메서드를 지정하고 필요한
atest
명령줄 옵션을 추가합니다.
테스트 관련 도움말
- 타겟팅된 테스트: 시간을 절약하기 위해 필요한 특정 테스트만 실행합니다.
Module:Class#Method
형식 또는 기타 atest
필터를 사용하세요.
- 에뮬레이터 스냅샷 사용: 에뮬레이터에서 테스트를 더 빠르게 실행하려면 스냅샷을 사용하여 알려진 양호한 상태로 빠르게 되돌리는 것이 좋습니다.
- 로그 확인: 실행 도구 창의 로그를 사용하여 테스트 실패를 진단합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-09-05(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-05(UTC)"],[],[],null,["Android Studio for Platform (ASfP) integrates with the `atest` command-line\ntool, letting you run tests on your connected device or emulator directly from\nthe IDE.\n\nPrerequisites\n\n- Open an ASfP project with your AOSP source code.\n- Successfully build and flash your code to a device or emulator.\n- Initialize your build environment using `source build/envsetup.sh` and `lunch`.\n\nRun tests\n\nYou can run tests using `atest` in ASfP in several ways:\n\n- **Gutter run icons:** Click the **Run** icon play_circle\n\n next to a test class or method in the editor to run that specific test.\n- **Right-click menu:** Right-click on a test file, class, or method in the\n Project window or editor and select **Run 'atest'**.\n\n- **Using the terminal:** Open the integrated terminal in ASfP (**View \\\u003e Tool\n Windows \\\u003e Terminal** ) and run `atest` commands directly. For example: `bash\n atest MyTestModule\n atest MyTestClass#myTestMethod`\n\nView test results\n\nTest results are displayed in the **Run** tool window within ASfP. This window\nshows the test progress, pass or fail status, and provides logs and output for\neach test.\n\nTest configurations\n\nWhen you run a test from the gutter or right-click menu, ASfP automatically\ncreates a temporary run or debug configuration. You can modify and save these\nconfigurations to quickly re-run tests with specific options or flags:\n\n1. Go to **Run \\\u003e Edit Configurations**.\n2. Find the `atest` configuration you want to modify or create a new one by clicking the **+** button and selecting **atest**.\n3. Specify the test module, class, method, and add any necessary `atest` command-line options.\n\nTips for testing\n\n- **Targeted testing:** Run only the specific tests you need to save time. Use the format `Module:Class#Method` or other `atest` filters.\n- **Use emulator snapshots:** For faster test runs on emulators, consider using snapshots to quickly revert to a known good state.\n- **Check logs:** Use the logs in the **Run** tool window to diagnose any test failures."]]