I created a rather simple Apex class VF11_controller in sandbox, which I'm looking to deploy to production. This apex class has one dependency, a VF page, which I added too in the change dataset. After creating the simplest test class for the controller in sandbox, I see a code coverage of 89%, good enough for deployment right:
However, after upload and attempt to deploy with the same user in production, I get the dreaded error:
Something is way off here cause it says test coverage is 0%! I'm sharing as much info as possible so the cause of error can be identified and removed. Here is my test class:
@isTest(SeeAllData=true)
class Test_VF11_Controller{
static testMethod void test(){
account acc = new account(name='Acc1');
insert acc;
contact cont = new contact(firstname='Jessie',lastname='Brown',email='[email protected]',accountid=acc.id);
insert cont;
VF11_Controller con = new VF11_Controller(new ApexPages.StandardController(cont));
attachment att = new attachment(name='newAtt',body=blob.ValueOf('random text'),parentId=con.contact_id);
insert att;
con.cc = '[email protected]';
con.bcc = '[email protected]';
con.attachment1.name = 'upload';
con.attachment1.body = blob.ValueOf('upload random text');
boolean selected = false;
VF11_Controller.attachwrapper wrap = new VF11_Controller.attachwrapper(att);
wrap.acc = att;
wrap.selected = false;
con.getSelectedattachments();
con.getSelected();
wrap.selected = true;
con.getSelected();
con.attach_new();
con.sendEmail();
}
}
And finally, here's the entire red and blue color code of the Apex controller (89% covered) that I need to deploy to prod (please zoom in to view better):
What could be causing this? Also, I noticed something pretty strange - occasionally after a refresh or returning to the page of apex classes, I see the code coverage of VF11_controller down to 0%! But I always made sure it's 89% last when I check, right before uploading from sandbox.
I also tried removing the hard-coded email template ids from the controller and then deploying; no easy luck.