测试和调试 Apps 脚本 Google Workspace 插件
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
发布插件后,用户可以通过托管应用或 Google Workspace Marketplace 安装该插件。在发布之前,请在扩展的托管应用中测试您开发的插件。
本页介绍了如何安装正在开发的插件(称为未发布或开发者插件),以供测试或个人使用。您还可以使用 Google Apps Script IDE 的调试程序和断点调试插件。
前提条件
- 您必须对该插件脚本项目拥有“编辑者”权限。
- 如需让贵组织中的其他人测试该插件,请向他们授予脚本项目的编辑器访问权限。如需详细了解如何授予访问权限,请参阅与其他开发者协作。
安装未发布的插件
您可以通过 Apps 脚本的部署对话框安装未发布的插件。
如需安装未发布的 Google Workspace 插件以进行测试,请按以下步骤操作:
- 在 Apps Script 编辑器中打开脚本项目。
- 依次点击部署 > 测试部署。
- 点击安装。
- 点击底部的完成。
您可以与其他用户的账号共享 Apps 脚本项目(需要拥有编辑权限),以便他们测试该插件。然后,提示用户按照上述步骤操作。
安装后,该插件会立即在其扩展的托管应用中可用。您可能需要刷新主机应用标签页,然后才能看到该插件。您还必须先授权该插件,然后才能使用它。
卸载未发布的插件
如需卸载未发布的插件部署,请按以下步骤操作:
- 在 Apps Script 编辑器中打开脚本项目。
- 依次点击部署 > 测试部署。
- 点击卸载。
- 点击底部的完成。
这些步骤会立即移除部署,并且该插件将不再显示在任何托管应用中。您可以随时重新安装部署,只需重复安装步骤即可。
测试最佳实践
在测试 Google Workspace 插件时,请务必遵循插件开发最佳实践。此外,请务必执行以下操作:
在该插件扩展的所有宿主应用中全面测试卡片导航流程。确保在用户从一个情境切换到另一个情境,以及在非情境卡片和情境卡片之间切换时,插件行为正确无误。
使用示例测试数据评估您的插件行为。
如果您的插件连接到第三方 API 或其他服务,请验证该服务是否可访问且行为是否符合预期。确保您的插件正确处理授权和登录详细信息。
确保妥善处理所有错误情况。根据需要使用错误卡片。
请注意该插件性能如何。如果您更改了代码,而插件开始运行缓慢,您可能需要移除或重新调整该功能。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-22。
[null,null,["最后更新时间 (UTC):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."]]