हमारा सुझाव है कि 27 मार्च, 2025 से AOSP को बनाने और उसमें योगदान देने के लिए, aosp-main
के बजाय android-latest-release
का इस्तेमाल करें. ज़्यादा जानकारी के लिए, AOSP में हुए बदलाव लेख पढ़ें.
GoogleTest
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
प्लैटफ़ॉर्म के लिए GoogleTest (GTest, जिसे कभी-कभी "नेटिव टेस्ट" भी कहा जाता है), आम तौर पर निचले लेवल के एचएएल को ऐक्सेस करता है या अलग-अलग सिस्टम सेवाओं के लिए रॉ आईपीसी करता है. इस वजह से, टेस्टिंग का तरीका आम तौर पर, जांच की जा रही सेवा के साथ ज़्यादा जुड़ा होता है.
लगातार टेस्टिंग इन्फ़्रास्ट्रक्चर के साथ इंटिग्रेट करने के लिए, GTest फ़्रेमवर्क का इस्तेमाल करके GTests बनाएं.
उदाहरण
यहां प्लैटफ़ॉर्म सोर्स में GTest के कुछ उदाहरण दिए गए हैं:
चरणों की खास जानकारी
GTest मॉड्यूल सेटअप करने के उदाहरण का पालन करें.
GTest की डिपेंडेंसी अपने-आप शामिल करने के लिए, अपने टेस्ट मॉड्यूल कॉन्फ़िगरेशन में BUILD_NATIVE_TEST
बिल्ड नियम का इस्तेमाल करें.
साधारण और जटिल विकल्पों के उदाहरणों का पालन करके, टेस्ट कॉन्फ़िगरेशन लिखें.
इंक्रीमेंटल बिल्ड के लिए mmm
या पूरे बिल्ड के लिए mma
का इस्तेमाल करके, टेस्ट मॉड्यूल बनाएं:
make hwui_unit_tests -j
Atest का इस्तेमाल करके, टेस्ट को लोकल तौर पर चलाएं:
atest hwui_unit_tests
GTests में आर्ग्युमेंट भी जोड़े जा सकते हैं. ये आर्ग्युमेंट खास तौर पर काम के होते हैं:
native-test-flag
, GTest शेल कमांड को पास करने के लिए अतिरिक्त फ़्लैग वैल्यू तय करता है.
native-test-timeout
, टेस्ट टाइम आउट की वैल्यू को माइक्रोसेकंड में बताता है.
नीचे दिए गए उदाहरण में, इन दोनों आर्ग्युमेंट का इस्तेमाल किया गया है:
atest test-name -- --module-arg test-name:native-test-flag:"\"argument1 argument2\"" \
--module-arg test-name:native-test-timeout:60000
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 की बेहतर गाइड देखें.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. 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,["# 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)."]]