2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
테스트 실행기 구조
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
테스트 실행기는 호출 흐름의 실행 단위입니다. 여기서 실제로 테스트가 실행됩니다.
인터페이스
테스트 실행기는 IRemoteTest 인터페이스를 통해 정의됩니다. 이 인터페이스는 테스트 실행 시 호출되는, 구현할 간단한 run
메서드를 제공합니다.
이렇게 하면 가장 단순한 의미의 테스트 실행이 발생할 수 있습니다. 하지만 실제 과정에서는 테스트 작성자에게 빌드 및 기기 정보 등 추가 정보가 있어야 테스트를 제대로 작성할 수 있습니다. 이러한 경우에는 다음과 같은 인터페이스가 유용할 수 있습니다.
기본
아래의 두 인터페이스는 현재 가장 광범위하게 사용되고 있으며, 대부분의 테스트와 관련된 기본적인 요구사항을 나타냅니다.
- IBuildReceiver는 테스트가 빌드 제공업체 단계에서 생성된
IBuildInfo
객체를 가져오도록 허용합니다. 이 단계에는 테스트 설정과 관련된 모든 정보와 아티팩트가 포함되어 있습니다.
- IDeviceTest는 테스트 중인 기기를 나타내는
ITestDevice
객체의 수신을 허용하고 객체와 상호작용하는 API를 제공합니다.
고급
테스트 하네스와 테스트 실행기 간의 좀 더 복잡한 상호작용을 가능하게 해주는 추가적인 인터페이스가 있습니다.
- ITestFilterReceiver는 테스트가 특정 테스트만 실행하도록 하기 위한 필터 모음을 수신할 수 있게 해줍니다. 이는 테스트의 하위 집합을 실행하는 경우에 유용합니다.
- ITestCollector는 테스트 실행기가 테스트를 실제로 실행하는 대신 시험적 실행만 할 수 있게 해줍니다. 이는 모든 테스트 사례의 목록을 수집할 때 유용합니다.
기존 테스트 실행기
다양한 테스트 실행기가 이미 존재하며, 이 중 일부는 주요 테스트 유형과 관련이 있습니다.
위의 테스트 외에도 다수의 맞춤 테스트 실행기가 존재합니다. 이러한 테스트는 부팅 테스트와 같은 일부 기능 테스트와 관련된 특수한 용도로 사용됩니다.
새 테스트 실행기 작성
새 테스트 실행기 작성에 관한 자세한 내용은 테스트 작성 섹션을 참고하세요.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 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,["# Structure of a test runner\n\nThe test runner is the execution unit of the invocation flow. This is where\ntests actually run.\n\nInterfaces\n----------\n\nTest runners are defined via the [IRemoteTest\ninterface](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/invocation_interfaces/com/android/tradefed/testtype/IRemoteTest.java),\nwhich provides a simple `run` method to implement that will be called when the\ntests is to run.\n\nThis allows the simplest definition of a test run to occur. But in practice,\ntest writers will need more information to properly write their tests, typically\nbuild and device information. This is where the following interfaces come handy.\n\n### Basic\n\nThese two interfaces are the most widely used today, as they represent the basic\nneeds of most tests.\n\n- [IBuildReceiver](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/IBuildReceiver.java) allows the test to get the `IBuildInfo` object created at the [build\n provider](/docs/core/tests/tradefed/architecture/build-provider) step containing all the information and artifacts related to the test setup.\n- [IDeviceTest](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/IDeviceTest.java) allows TF to receive the `ITestDevice` object that represents the device under test and provides an API to interact with it.\n\n### Advanced\n\nThere are additional interfaces that allow more complex interaction between the\ntest harness and the test runner:\n\n- [ITestFilterReceiver](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/ITestFilterReceiver.java), which allows the test to receive a set of filters for running certain tests only. This is useful in running a subset of the tests.\n- [ITestCollector](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/ITestCollector.java), which allows a test runner to only dry-run the tests instead of actually executing them. This is useful in collecting the list of all test cases.\n\nExisting test runners\n---------------------\n\nA variety of test runners already exists, some for major test types:\n\n- [AndroidJUnitTest / InstrumentationTest](/reference/tradefed/com/android/tradefed/testtype/AndroidJUnitTest) (associated with AJUR on the device side)\n- [GTest](/reference/tradefed/com/android/tradefed/testtype/GTest) (device and host side) with [googletest library](https://github.com/google/googletest)\n- [Host-driven\n tests](/reference/tradefed/com/android/tradefed/testtype/HostTest) (Java tests that execute on the host and call the device from there)\n- [Pure Java unit\n tests](/reference/tradefed/com/android/tradefed/testtype/HostTest) (our runner does both)\n- [Python tests](/reference/tradefed/com/android/tradefed/testtype/python/PythonBinaryHostTest)\n- [Google Benchmark\n tests](/reference/tradefed/com/android/tradefed/testtype/GoogleBenchmarkTest) with [benchmark library](https://github.com/google/benchmark)\n\nA large number of custom test runners exist besides the above; they serve\nspecialized purposes for some functional testing, for example Boot Test.\n\nWrite a new test runner\n-----------------------\n\nMore guidance of writing a new test runner is available in the [writing tests\nsection](/docs/core/tests/tradefed/testing/through-tf/new-test-runner)."]]