I have been struggling with this for 5 hours now and can't find a solution.
I am trying to push my code from the sandbox to production but when I try to validate the deployment in the production environment I am getting this error:
- Code Coverage Failure Your organization's code coverage is 65%. You need at least 75% coverage to complete this deployment.
When I run all of my test classes in the sandbox I am at 80% coverage. I am uploading the apex classes, trigger, & test class in the package and they all test above the threshold. This is just an update to the code so I have been able to deploy to production in the past. Any help or suggestions would be greatly appreciated.
@isTest (SeeAllData=false)
static void TestTrigger()
{
Account newAccount = new Account (name = 'Test',
BillingCity ='TestCity',
BillingCountry ='TestCountry',
BillingStreet ='TestStreet',
BillingPostalCode ='t3stcd3'
);
insert newAccount;
if(newAccount.Id != null)
{
Contact newContact = new Contact (
FirstName = 'xyzFirst',
LastName = 'XyZLast',
AccountId = newAccount.Id,
Email = 'xyzmail@mail.com'
);
insert newContact;
}
return;
}
return;is not used in a Test method. Move your closing bracket for yourif(newAccount.Id != null)statement to beforeinsert newContact;and just before the insert statement, you should have atest.startTest;– crmprogdev Dec 30 '14 at 17:22