How do I create Test Data for an Org. Wide Email Address?
You can't set up an OrgWideEmailAddress
. Attempting to do so gives this error:
DML operation Insert not allowed on OrgWideEmailAddress
Fortunately, you can see them perfectly fine without SeeAllData=true
. I even took the time to verify it with a simple unit test:
// This class is in version 43.0, SeeAllData=false by default
@isTest class q224877 {
@isTest static void test() {
OrgWideEmailAddress[] addresses = [SELECT Id FROM OrgWideEmailAddress LIMIT 1];
System.assertEquals(1, addresses.size());
}
}
This test, of course, passes. Typically speaking, when you're not sure if something applies to your scenario, write a unit test. Doing so saves you the trouble of trying to figure out something like this and waiting for an answer. This test took me about a minute to type up.