اختبار إضافة المحرِّر
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يجب اختبار الإضافات بدقة قبل نشرها لضمان أنّها تعمل على النحو المطلوب. تتيح لك أداة Apps Script اختبار
إضافات المحرِّر
قيد التطوير في ملفات معيّنة من "مستندات Google" أو "جداول بيانات Google" أو "نماذج Google" أو "العروض التقديمية من Google". يمكن استخدام هذه الميزة للقيام بما يلي:
- تأكَّد من أنّ الإضافة المكتوبة في نص برمجي مستقل تعمل على النحو المطلوب
عند تطبيقها على جدول بيانات أو مستند أو عرض تقديمي أو نموذج.
- تأكَّد من أنّ عملية تثبيت الإضافة تعمل على النحو المطلوب، لا سيما في ما يتعلّق
بحالات مختلفة لمراحل دورة حياة التفويض
(مثبَّت أو مفعَّل أو كليهما).
- تأكَّد من أنّ الإضافة تعمل على النحو المطلوب عند معالجة مستند معيّن
ومحتواه.
- اختبِر الإصدارَين الحالي والسابق من الإضافة وقارِن بينهما.
إنشاء عملية نشر تجريبية
النشر التجريبي هو مزيج من إضافة ومستند اختباري.
بعد تطوير إصدار من النص البرمجي ورغبتك في اختباره كإضافة،
اتّبِع الخطوات التالية:
- إذا لم يكن لديك جدول بيانات أو مستند أو
عرض تقديمي أو نموذج، أنشئ واحدًا لاختبار الإضافة.
- افتح مشروع النصوص البرمجية الذي يحتوي على الإضافة.
- انقر على نشر > اختبار عمليات النشر.
- بجانب اختيار النوع، انقر على رمز تفعيل أنواع عمليات النشر settings
واختَر إضافة المحرِّر.
- انقر على إنشاء اختبار جديد أو إضافة اختبار.
- اختَر إصدار الرمز أو انقر على أحدث رمز.
- في قسم الإعداد، اختَر حالة التفويض الأولية للاختبار.
- ضمن مستند الاختبار، انقر على لم يتم اختيار أي مستند. اختَر ملف "جداول بيانات Google" أو "مستندات Google"
أو "العروض التقديمية من Google" أو "نماذج Google" الذي تريد استخدامه لاختبار الإضافة، ثم انقر على إدراج.
- انقر على حفظ الاختبار.
تظهر جميع عمليات النشر الاختبارية المحفوظة في مربّع الحوار عمليات النشر الاختبارية. يتيح لك ذلك
إعادة الاطّلاع على عملية النشر التجريبية نفسها لاحقًا.
إجراء عملية نشر تجريبية
إذا كان لديك عملية واحدة أو أكثر من عمليات النشر التجريبية المحفوظة، يمكنك تنفيذ إحدى هذه العمليات باتّباع الخطوات التالية:
- افتح مشروع النصوص البرمجية الذي يحتوي على الإضافة.
- انقر على نشر > اختبار عمليات النشر.
- ضمن الاختبارات المحفوظة، انقر على زر الاختيار بجانب عملية نشر الاختبار
المحفوظة التي تريد تنفيذها، ثم انقر على تنفيذ.
يتم فتح مستند الاختبار في علامة تبويب جديدة. تكون الإضافة في
حالة التفويض
المحدّدة في عملية النشر التجريبية. يمكنك التحقّق من أنّ الإضافة تعمل على النحو المقصود من خلال التفاعل مع قائمتها وعناصر واجهة المستخدم.
تفاصيل الاختبار
هناك عدد من الأمور التي يجب أخذها في الاعتبار أثناء اختبار إضافات "محرّر إعلانات Google"
بهذه الطريقة:
- عوامل التشغيل القابلة للتثبيت
غير متوافقة عند الاختبار. لا يمكن اختبار الوظائف التي تعتمد على عوامل التفعيل القابلة للتثبيت.
- أثناء تنفيذ عملية نشر تجريبية تم ضبطها للاختبار باستخدام أحدث رمز،
يمكنك الاطّلاع على التغييرات المحفوظة في النص البرمجي للإضافة من خلال إعادة تحميل مستند الاختبار.
- يحتوي المستند التجريبي على عنوان URL يمكنك مشاركته مع محرّري المستند التجريبي الأصلي. بهذه الطريقة، يمكنك التعاون مع الآخرين بسهولة أكبر أثناء
الاختبار والتطوير.
- إذا كانت الإضافة تستخدِم
خدمة المواقع،
تبقى المواقع محفوظة وتظلّ متاحة في المرة التالية التي يتم فيها تنفيذ عملية النشر الاختباري.
- بالإضافة إلى ذلك، يمكن لأي عملية نشر تجريبية تستخدم التركيبة نفسها من الإضافة ومقتطف الاختبار الوصول إلى معلومات الموقع نفسها. على سبيل المثال، إذا
أنشأت عمليتَي نشر تجريبية، تكون السمات المحفوظة أثناء تنفيذ العملية الأولى
متوفّرة أثناء تنفيذ العملية الثانية والعكس صحيح، ولكن فقط إذا كانت عمليات النشر
تستخدم النص البرمجي ومستند الاختبار نفسهما.
- في حال إجراء عملية نشر تجريبية، قد يُطلب منك منح الإذن إذا
لم يسبق لك تشغيل النص البرمجي. يُرجى العِلم أنّ منح الإذن للنص البرمجي أثناء
الاختبار يؤدي أيضًا إلى منح الإذن للنص البرمجي خارج نطاق الاختبار.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2024-12-22 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2024-12-22 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eApps Script allows developers to test editor add-ons directly within Google Docs, Sheets, Slides, or Forms to verify functionality and installation flow.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can create test deployments to specify add-on versions, authorization states, and associated documents for controlled testing environments.\u003c/p\u003e\n"],["\u003cp\u003eSaved test deployments can be executed repeatedly, enabling developers to iterate on their add-ons and observe changes in real-time within the test document.\u003c/p\u003e\n"],["\u003cp\u003eWhile offering valuable testing capabilities, test deployments have limitations such as not supporting installable triggers and shared property persistence across deployments using the same add-on and document.\u003c/p\u003e\n"],["\u003cp\u003eTest deployments provide a shareable URL for collaborative testing and may require authorization for the script, both within and outside the testing environment.\u003c/p\u003e\n"]]],["To test add-ons in development, create a test deployment linking a script version to a specific Google Docs, Sheets, Forms, or Slides file. Select the add-on's authorization state and save the test. Run saved tests by selecting them in the \"Test deployments\" dialog and clicking \"Execute.\" During testing, changes to the script can be viewed by refreshing the test document; the test document URL is shareable for collaboration. Any properties created are also persisted across multiple test deployments.\n"],null,["# Test an Editor add-on\n\nAdd-ons should be tested thoroughly prior to publishing to ensure they\nbehave as intended. Apps Script lets you test\n[Editor add-ons](/workspace/add-ons/concepts/types#editor_add-ons)\nin development on specific Google Docs Sheets, Forms, or Slides files. This\ncan be used to:\n\n- Verify that an add-on written in a standalone script functions as intended when applied to a sheet, doc, presentation, or form.\n- Verify that the add-on installation flow works as intended, particularly for different initial [authorization lifecycle states](/workspace/add-ons/concepts/editor-auth-lifecycle#the_complete_lifecycle) ([installed, enabled, or both](/workspace/add-ons/concepts/editor-auth-lifecycle#installed_versus_enabled)).\n- Verify that the add-on functions as intended when acting on a particular document and its contents.\n- Test and compare the current and previous versions of the add-on.\n\nCreate a test deployment\n------------------------\n\nA test deployment is the combination of an add-on and a test document.\nOnce you have a script version developed and would like to test it as an add-on,\nfollow these steps:\n\n1. If you don't have one already, create a spreadsheet, document, presentation, or form to test the add-on with.\n2. Open the script project containing your add-on.\n3. Click **Deploy** \\\u003e **Test deployments**.\n4. Next to **Select type** , click Enable deployment types settings and select **Editor add-on**.\n5. Click **Create new test** or **Add test**.\n6. Choose a code version or select **Latest Code**.\n7. In the **Config** section, select the initial [authorization state](/workspace/add-ons/concepts/editor-auth-lifecycle#installed_versus_enabled) for the test.\n8. Under **Test document** , click **No document selected** . Select the Sheets, Docs, Slides, or Forms file you want to use to test the add-on and click **Insert**.\n9. Click **Save test**.\n\nAll saved test deployments appear in the **Test deployments** dialog. This lets\nyou revisit the same test deployment later on.\n\nRun a test deployment\n---------------------\n\nIf you have one or more saved test deployments, you can run one of them by\nfollowing these steps:\n\n1. Open the script project containing your add-on.\n2. Click **Deploy** \\\u003e **Test deployments**.\n3. Under **Saved Tests** , select the radio button next to the saved test deployment you want to run and click **Execute**.\n\nThe test document opens in a new tab. The add-on is in the\n[authorization state](/workspace/add-ons/concepts/editor-auth-lifecycle#installed_versus_enabled)\nspecified in the test deployment. You can verify that the add-on functions as\nintended by interacting with its menu and UI elements.\n\n### Testing details\n\nThere are a number of things to keep in mind while testing Editor add-ons\nthis way:\n\n- [Installable triggers](/workspace/add-ons/concepts/editor-triggers#installable_triggers_in_add-ons) aren't supported when testing. Functionality that depends on installable triggers is not testable.\n- While running a test deployment that's set to test with the latest code, you can see changes saved to the add-on script by refreshing the test document.\n- The test document has a URL that you can share with editors of the original test document. This way, you can more easily collaborate with others while testing and developing.\n- If your add-on uses the [Properties service](/apps-script/reference/properties/properties-service), properties persist and remain available the next time the test deployment is run.\n- In addition, any test deployment that uses the same combination of add-on and test document has access to the same property information. For example, if you create two test deployments, the properties saved while running the first are available while running the second and vice versa, but only if the deployments use the same script and test document.\n- If you run a test deployment, you might be prompted for authorization if you have not run the script before. Be aware that authorizing a script while testing also authorizes the script outside of testing."]]