हमारा सुझाव है कि 27 मार्च, 2025 से AOSP को बनाने और उसमें योगदान देने के लिए, aosp-main
के बजाय android-latest-release
का इस्तेमाल करें. ज़्यादा जानकारी के लिए, AOSP में हुए बदलाव लेख पढ़ें.
टेस्ट रनर का स्ट्रक्चर
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
टेस्ट रनर, कॉल करने के फ़्लो की एक्ज़ीक्यूशन यूनिट है. यहां पर ही जांच की जाती है.
इंटरफ़ेस
टेस्ट रनर को IRemoteTest इंटरफ़ेस के ज़रिए तय किया जाता है. यह लागू करने के लिए एक आसान run
तरीका उपलब्ध कराता है. इसे टेस्ट चलाने के दौरान कॉल किया जाएगा.
इससे, टेस्ट रन की आसानी से परिभाषा तय की जा सकती है. हालांकि, आम तौर पर, टेस्ट लिखने वाले लोगों को अपने टेस्ट को सही तरीके से लिखने के लिए ज़्यादा जानकारी की ज़रूरत होती है. जैसे, बिल्ड और डिवाइस की जानकारी. ऐसे में, यहां दिए गए इंटरफ़ेस काम आते हैं.
सामान्य
फ़िलहाल, इन दोनों इंटरफ़ेस का सबसे ज़्यादा इस्तेमाल किया जाता है, क्योंकि ये ज़्यादातर टेस्ट की बुनियादी ज़रूरतों को पूरा करते हैं.
- IBuildReceiver, जांच को बिल्ड प्रोवाइडर चरण में बनाया गया
IBuildInfo
ऑब्जेक्ट पाने की अनुमति देता है. इसमें जांच सेटअप से जुड़ी सभी जानकारी और आर्टफ़ैक्ट होते हैं.
- IDeviceTest की मदद से, TF को
ITestDevice
ऑब्जेक्ट मिलता है. यह ऑब्जेक्ट, जांच में शामिल डिवाइस के बारे में जानकारी देता है. साथ ही, इससे इंटरैक्ट करने के लिए एक एपीआई भी मिलता है.
बेहतर
कुछ और इंटरफ़ेस भी हैं, जिनकी मदद से टेस्ट हार्नेस और टेस्ट रनर के बीच ज़्यादा जटिल इंटरैक्शन किया जा सकता है:
- ITestFilterReceiver,
इसकी मदद से टेस्ट को सिर्फ़ कुछ टेस्ट चलाने के लिए फ़िल्टर का सेट मिलता है. यह टेस्ट के सबसेट को चलाने में मददगार होता है.
- ITestCollector,
इसकी मदद से टेस्ट रनर, टेस्ट को असल में चलाने के बजाय सिर्फ़ ड्राई-रन कर सकता है. यह सभी टेस्ट केस की सूची इकट्ठा करने में मददगार है.
मौजूदा टेस्ट रनर
कई तरह के टेस्ट रनर पहले से मौजूद हैं. इनमें से कुछ, मुख्य टेस्ट टाइप के लिए हैं:
ऊपर बताए गए टेस्ट रनर के अलावा, ज़्यादातर कस्टम टेस्ट रनर मौजूद हैं. ये कुछ फ़ंक्शनल टेस्टिंग के लिए खास काम करते हैं. जैसे, बूट टेस्ट.
नया टेस्ट रनर लिखना
नया टेस्ट रनर लिखने के बारे में ज़्यादा जानकारी के लिए, टेस्ट लिखने का सेक्शन देखें.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, 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)."]]