測試及偵錯 Apps Script Google Workspace 外掛程式
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
發布外掛程式後,使用者就能透過主機應用程式或 Google Workspace Marketplace 安裝。發布前,請測試您在主機應用程式中開發的擴充功能。
本頁說明如何安裝開發中的外掛程式 (稱為未發布或開發人員外掛程式),以供測試或個人使用。您也可以使用 Apps Script IDE 的偵錯工具和中斷點來偵錯外掛程式。
必要條件
- 你必須具備外掛程式指令碼專案的編輯者存取權。
- 如要讓貴機構的其他使用者測試外掛程式,請授予他們指令碼專案的編輯者存取權。如要進一步瞭解如何授予存取權,請參閱「與其他開發人員合作」。
安裝未發布的外掛程式
您可以透過 Apps Script 的部署對話方塊,安裝未發布的外掛程式。
如要安裝未發布的 Google Workspace 外掛程式進行測試,請按照下列步驟操作:
- 在 Apps Script 編輯器中開啟指令碼專案。
- 依序按一下「Deploy」>「Test deployments」。
- 按一下 [安裝]。
- 按一下底部的「完成」。
您可以將 Apps Script 專案與其他使用者的帳戶共用 (需要編輯存取權),讓他們測試外掛程式。然後提示使用者按照上述步驟操作。
安裝完畢後,外掛程式會立即在擴充的代管應用程式中提供。您可能需要重新整理主機應用程式分頁,才能顯示外掛程式。您也必須先授權外掛程式,才能使用。
解除安裝未發布的外掛程式
如要解除安裝未發布的外掛程式部署,請按照下列步驟操作:
- 在 Apps Script 編輯器中開啟指令碼專案。
- 依序按一下「Deploy」>「Test deployments」。
- 按一下 [Uninstall] (解除安裝)。
- 按一下底部的「完成」。
這些步驟會立即移除部署作業,且外掛程式不會再出現在任何主機應用程式中。您隨時可以重複執行安裝程序,重新安裝部署作業。
測試最佳做法
測試 Google Workspace 外掛程式時,請務必遵循外掛程式開發的最佳做法。此外,請務必完成下列事項:
在擴充外掛程式的所有主機應用程式中,徹底測試資訊卡導覽流程。請確認在使用者從一個情境移動到另一個情境,以及在非情境和情境資訊卡之間移動時,外掛程式行為是否正確。
使用範例測試資料來評估外掛程式的行為。
如果外掛程式連結至第三方 API 或其他服務,請確認可以存取該服務,且運作情況符合預期。請確認外掛程式是否正確處理授權和登入詳細資料。
請確認所有錯誤狀況都能妥善處理。視需要使用錯誤資訊卡。
請留意外掛程式的效能。如果您變更程式碼後,外掛程式開始變慢,您可能需要移除或重新調整該功能。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-22 (世界標準時間)。
[null,null,["上次更新時間:2024-12-22 (世界標準時間)。"],[[["\u003cp\u003eUnpublished Google Workspace add-ons can be installed for testing and personal use directly from the Apps Script project.\u003c/p\u003e\n"],["\u003cp\u003eUsers need editor access to the script project to install and test the unpublished add-on.\u003c/p\u003e\n"],["\u003cp\u003eUninstalling an unpublished add-on removes it from all host applications and requires reinstallation for further use.\u003c/p\u003e\n"],["\u003cp\u003eThorough testing is crucial, including card navigation, data handling, external service integrations, error management, and performance evaluation.\u003c/p\u003e\n"]]],["To test an unpublished add-on, open its script project in the Apps Script editor and navigate to **Deploy \u003e Test deployments**. Click **Install**, then **Done** to make it available in host applications. Share the project for others to test. Uninstall by repeating the process and selecting **Uninstall**. Testing should include card navigation, example data evaluation, third-party service verification, error handling, and performance monitoring.\n"],null,["# Test and debug Apps Script Google Workspace add-ons\n\nWhen you publish an add-on, users can install it\nthrough the host application\nor the [Google Workspace Marketplace](https://workspace.google.com/marketplace/). Before you publish, test the\nadd-ons that you develop within the host applications that\nthey extend.\n\nThis page describes how to install an add-on that is\nunder development (called an *unpublished* or *developer*\nadd-on) for testing or\npersonal use. You can also debug add-ons using the\nApps Script\nIDE's [debugger and breakpoints](/apps-script/guides/support/troubleshooting#use-debugger).\n\nPrerequisites\n-------------\n\n- You must have editor access to the add-on's script project.\n- To let other people in your organization test the add-on, grant them editor access to the script project. For details about granting access, see [Collaborating with Other Developers](/apps-script/guides/collaborating).\n\nInstall an unpublished add-on\n-----------------------------\n\nYou can install unpublished add-ons from Apps Script's **Deployments**\ndialog.\n\nFollow these steps to install an unpublished\nGoogle Workspace add-on for testing:\n\n1. Open the script project in the Apps Script editor.\n2. Click **Deploy \\\u003e Test deployments**.\n3. Click **Install**.\n4. At the bottom, click **Done**.\n\nYou can let other users test the add-on by sharing the Apps Script project\nwith their account (edit access is required). Then prompt the users to\nfollow the above steps.\n\nOnce installed, the add-on is immediately available in host applications it\nextends. You may need to refresh the host application tab before the add-on\nappears. You must also\n[authorize](/workspace/add-ons/how-tos/authorizing-addons#authorizing_unpublished_g_suite_add-ons)\nthe add-on before using it.\n\nUninstall an unpublished add-on\n-------------------------------\n\nTo uninstall an unpublished add-on deployment, follow these steps:\n\n1. Open the script project in the Apps Script editor.\n2. Click **Deploy \\\u003e Test deployments**.\n3. Click **Uninstall**.\n4. At the bottom, click **Done**.\n\nThese steps immediately remove the deployment and the add-on no longer appears\nin any host application. You can reinstall the deployment at any time by\nrepeating the [install procedure](#install_an_unpublished_add-on).\n\nTesting best practices\n----------------------\n\nWhile testing your Google Workspace add-on, be sure\nto follow the\n[Best practices](/workspace/add-ons/guides/workspace-best-practices)\nfor add-on development. In addition, be sure to do the following:\n\n1. Test card navigation flows thoroughly in all the host applications the\n add-on extends. Make sure the add-on behavior is correct as the user moves\n from context to context, and between non-contextual and contextual cards.\n\n2. [Use example test data](/workspace/add-ons/guides/workspace-best-practices#_write_tests_and_test_messages)\n to evaluate your add-on's behavior.\n\n3. If your add-on connects to a third-party API or other service, verify\n that the service can be accessed and behaves as expected. Make sure\n your add-on is handling the\n [authorization and log-in details](/workspace/add-ons/how-tos/non-google-services)\n correctly.\n\n4. Make sure any error conditions are handled gracefully. [Use error cards](/workspace/add-ons/guides/workspace-best-practices#_use_error_cards)\n where needed.\n\n5. Pay attention to how performant the add-on is. If you make a change to the\n code and the add-on starts slowing down, you may need to remove or rework\n that feature."]]