2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
GoogleTest
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
플랫폼의 GoogleTest(GTest, '네이티브 테스트'라고도 함)는 일반적으로 하위 수준 HAL에 액세스하거나 다양한 시스템 서비스를 대상으로 원시 IPC를 실행합니다. 이 때문에 테스트 접근 방식은 일반적으로 테스트 중인 서비스와 밀접한 관련이 있습니다.
지속적인 테스트 인프라와 통합하려면 GTest 프레임워크를 사용하여 GTest를 빌드합니다.
예
다음은 플랫폼 소스에 있는 GTest의 예입니다.
단계 요약
GTest 모듈 설정 예를 따릅니다.
GTest 종속 항목을 자동으로 포함하려면 테스트 모듈 구성에서 BUILD_NATIVE_TEST
빌드 규칙을 사용합니다.
단순한 옵션과 복잡한 옵션의 예에 따라 테스트 구성을 작성합니다.
증분 빌드에는 mmm
을 사용하고 전체 빌드에는 mma
를 사용하여 테스트 모듈을 빌드합니다.
make hwui_unit_tests -j
Atest를 사용하여 로컬에서 테스트를 실행합니다.
atest hwui_unit_tests
GTest에 인수를 추가할 수도 있습니다. 다음은 특히 유용한 인수입니다.
Trade Federation 테스트 하네스를 사용하여 테스트를 실행합니다.
make tradefed-all -j
tradefed.sh run template/local_min --template:map test=hwui_unit_tests
수동으로 설치 및 실행합니다.
생성된 테스트 바이너리를 기기로 푸시합니다.
adb push ${OUT}/data/nativetest/hwui_unit_tests/hwui_unit_tests \
/data/nativetest/hwui_unit_tests/hwui_unit_tests
GTest를 실행하고, 기기에서 테스트 바이너리를 호출하여 테스트를 실행합니다.
adb shell /data/nativetest/hwui_unit_tests/hwui_unit_tests
테스트 실행 맞춤설정에 관한 자세한 내용을 확인하려면 --help
매개변수를 테스트 바이너리에 추가하세요. 매개변수에 관한 자세한 내용은 GTest 고급 가이드를 참고하세요.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(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-07-27(UTC)"],[],[],null,["# GoogleTest\n\nA GoogleTest (GTest, also sometimes called \"native tests\") for the platform\ntypically accesses lower-level HALs or performs raw IPC against various system\nservices. Because of this, the testing approach is usually tightly coupled with\nthe service under test.\n\nTo integrate with continuous testing infrastructure, build your GTests\nusing the [GTest](https://github.com/google/googletest)\nframework.\n\nExamples\n--------\n\nHere are some examples of GTest in the platform source:\n\n- [frameworks/av/camera/tests](https://android.googlesource.com/platform/frameworks/av/+/android16-release/camera/tests/)\n- [frameworks/native/libs/gui/tests](https://android.googlesource.com/platform/frameworks/native/+/android16-release/libs/gui/tests/)\n\nSummary of steps\n----------------\n\n1. Follow the [example GTest module setup](https://android.googlesource.com/platform/frameworks/base/+/android16-release/libs/hwui/tests/unit/).\n\n2. To automatically include GTest dependencies, use the `BUILD_NATIVE_TEST`\n build rule in your test module configuration.\n\n3. Write a test configuration, following the examples for [simple](/docs/core/tests/development/blueprints)\n and [complex](/docs/core/tests/development/test-config) options.\n\n4. Build the test module with `mmm` for incremental builds, or `mma` for full\n builds:\n\n make hwui_unit_tests -j\n\n5. Run the test locally using [Atest](/docs/core/tests/development/atest):\n\n atest hwui_unit_tests\n\n You can also add arguments to your GTests. The following are especially useful arguments:\n - `native-test-flag` specifies additional flag values to pass to the GTest shell command.\n - `native-test-timeout` specifies a test timeout value in microseconds.\n\n The following example code uses both of these arguments: \n\n atest test-name -- --module-arg test-name:native-test-flag:\"\\\"argument1 argument2\\\"\" \\\n --module-arg test-name:native-test-timeout:60000\n\n6. Run the test with the Trade Federation test harness:\n\n make tradefed-all -j\n tradefed.sh run template/local_min --template:map test=hwui_unit_tests\n\n7. Manually install and run:\n\n 1. Push the generated test binary onto your device:\n\n adb push ${OUT}/data/nativetest/hwui_unit_tests/hwui_unit_tests \\\n /data/nativetest/hwui_unit_tests/hwui_unit_tests\n\n 2. Launch GTest and execute the test by invoking the test binary on the device:\n\n adb shell /data/nativetest/hwui_unit_tests/hwui_unit_tests\n\n For more information about customizing test execution, add the `--help`\n parameter to your test binary. For more information on parameters, refer to\n the [GTest advanced guide](https://github.com/google/googletest/blob/master/googletest/docs/advanced.md)."]]