Test coverage of selected Apex Trigger is 0%: meaning and how to fix it

Deployment Checked against the official docs on Source: SOAP API Developer Guide: Core Data Types, StatusCode

Quick answer

Test coverage of selected Apex Trigger is 0%: A trigger in the deployment has no test coverage. Triggers need some coverage to deploy to production. Start with: Write a test that inserts, updates or deletes records so the trigger runs.

Typical message: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

Cause

A trigger in the deployment has no test coverage. Triggers need some coverage to deploy to production.

How to fix Test coverage of selected Apex Trigger is 0%

  1. Write a test that inserts, updates or deletes records so the trigger runs.
  2. Include that test class in the deployment and run it.
  3. Make sure the test creates its own data and performs the DML the trigger listens for (insert, update or delete).
@isTest
private class AccountTriggerTest {
    @isTest static void insertsFireTrigger() {
        insert new Account(Name = 'Test');
    }
}

Have a different message? Paste it into the error decoder, which matches it against 45 common Salesforce errors in your browser.

Frequently asked questions

What does Test coverage of selected Apex Trigger is 0% mean in Salesforce?

A trigger in the deployment has no test coverage. Triggers need some coverage to deploy to production.

How do I fix Test coverage of selected Apex Trigger is 0%?

1. Write a test that inserts, updates or deletes records so the trigger runs. 2. Include that test class in the deployment and run it. 3. Make sure the test creates its own data and performs the DML the trigger listens for (insert, update or delete).

More Deployment errors

SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Message text varies slightly by release and context, so confirm against the official page before relying on it.