Test an Editor Add-on

Stay organized with collections Save and categorize content based on your preferences.

Add-ons should be tested thoroughly prior to publishing to ensure they behave as intended. Apps Script lets you test Editor Add-ons in development on specific Google Docs Sheets, Forms, or Slides files. This can be used to:

  • Verify that an add-on written in a standalone script functions as intended when applied to a sheet, doc, presentation, or form.
  • Verify that the add-on installation flow works as intended, particularly for different initial authorization lifecycle states (installed, enabled, or both).
  • Verify that the add-on functions as intended when acting on a particular document and its contents.
  • Test and compare the current and previous versions of the add-on.

Create a test deployment

A test deployment is the combination of an add-on and a test document. Once you have a script version developed and would like to test it as an add-on, follow these steps:

New editor

  1. If you don’t have one already, create a spreadsheet, document, presentation, or form to test the add-on with.
  2. Open the script project containing your add-on.
  3. Click Deploy > Test deployments.
  4. Next to Select type, click Enable deployment types and select Editor Add-on.
  5. Click Create new test or Add test.
  6. Choose a code version or select Latest Code.
  7. In the Config section, select the initial authorization state for the test.
  8. 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.
  9. Click Save test.

Legacy editor

  1. If you don’t have one already, create a spreadsheet, document, presentation, or form to test the add-on with.
  2. Open the script project containing your add-on.
  3. Open the script project containing your add-on in the script editor.
  4. (Optional) You may wish to save a new version of your project by selecting File > Manage versions, then Save New Version. Close the Manage Versions dialog.
  5. Click Run > Test as add-on.
  6. In the Select version box, choose a code version or select Test with latest code*.
  7. In the Installation Config box, select the initial authorization state for the test.
  8. Click the Select Doc button. This brings up a file select dialog. Find the test Sheet, Doc, Slides presentation, or Form you want to test the add-on on, click it, and then click Select to close the dialog.
  9. Click Save to save the test deployment.

All saved test deployments appear in the Test deployments dialog. This lets you revisit the same test deployment later on.

Run a test deployment

If you have one or more saved test deployments, you can run one of them by following these steps:

New editor

  1. Open the script project containing your add-on.
  2. Click Deploy > Test deployments.
  3. Under Saved Tests, select the radio button next to the saved test deployment you want to run and click Execute.

Legacy editor

  1. Open the script project containing your add-on in the script editor.
  2. Click Run > Test as add-on.
  3. Under Execute Saved Test, find the test to execute and select it.
  4. Click Test.

The test document opens in a new tab. The add-on is in the authorization state specified in the test deployment. You can verify that the add-on functions as intended by interacting with its menu and UI elements.

Testing details

There are a number of things to keep in mind while testing Editor Add-ons this way:

  • Installable triggers aren't supported when testing. Functionality that depends on installable triggers is not testable.
  • 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.
  • 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.
  • If your add-on uses the Properties service, properties persist and remain available the next time the test deployment is run.
  • 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.
  • 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.

Delete a test deployment

New editor

You must use the legacy editor to delete test deployments. To switch from the new editor to the legacy editor, at the top-right of the editor, click Use legacy editor.

Legacy editor

If you have one or more saved test deployments, you can delete one of them by following these steps:

  1. Open the script project containing your add-on in the script editor.
  2. Select Run > Test as add-on.
  3. Under Execute Saved Test, find the test to execute and select it.