function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion


This past weekend I went through a deployment and data migration. During the data migration, we accidentally triggered enough internal notifications to reach the governor limit on the Single Email Limit.

Afterwards, we ran into an issue where migrating a table triggered a null pointer exception - this is a side issue we know about where we need to get continuous integration and deployment setup. We wanted to release a hotfix for this bug, but when we went to promote our change to production our test methods failed because they test the process which sends the email and we received the SINGLE_EMAIL_LIMIT_EXCEEDED error. I can confirm the test and method is written efficiently as we were able to promote to a full sandbox and deploy the next day when the limit was reset.

After opening a ticket with support, I found out this is "working as intended". This baffled me that Salesforce would be designed to run a test against an exceeded limit that was not due to the test itself; I would imagine the test should have run against a clean slate similar to SOQL queries. This makes me wonder whether or not API Limits are reset for testing purposes. I know tests don't count towards that environment's governor limits, so I would expect the inverse as well.

I'm planning on creating an idea to support testing against a clean set of limits, but I wanted to understand why this would be designed this way. I get that only the product manager would truly be able to answer this, but I'm hoping to understand if my logic and process is inconsistent with testing and test method best practices. Salesforce Support suggested increasing governor limits prior to release, but based on the our number of records migrated we would have still hit that limit prior to deploying our hotfix.