You need to sign in to do that
Don't have an account?
Cameron Houser
Help with Test class testing renderAs
I am getting 56% coverage, I am also getting an Attempt to de-reference a null object with this line of code 'CustomerInfoSheet ac = new CustomerInfoSheet();'
@IsTest
public class CustomerInfoSheetTest {
static testMethod void testCustomerInfoSheet() {
Account a = new Account();
a.Name='TestAccount';
a.Industry='AG';
a.Region__c = 'Delta';
insert a;
a =[SELECT Id, Name, Industry, Region__c FROM Account testAccount WHERE Name=:a.Name];
system.assert(true, a.Id);
if (a != null) {
}
PageReference pageRef = Page.CustomerInfoSheet;
pageRef.getParameters().put('id',a.id);
test.setCurrentPage(pageRef);
CustomerInfoSheet ac = new CustomerInfoSheet();
test.startTest();
ac.PrintOut=a.Id;
pageRef = ac.CustomerInfoSheet();
System.assertEquals(pageRef.getUrl(), '/'+a.Id);
test.stopTest();
}
}
@IsTest
public class CustomerInfoSheetTest {
static testMethod void testCustomerInfoSheet() {
Account a = new Account();
a.Name='TestAccount';
a.Industry='AG';
a.Region__c = 'Delta';
insert a;
a =[SELECT Id, Name, Industry, Region__c FROM Account testAccount WHERE Name=:a.Name];
system.assert(true, a.Id);
if (a != null) {
}
PageReference pageRef = Page.CustomerInfoSheet;
pageRef.getParameters().put('id',a.id);
test.setCurrentPage(pageRef);
CustomerInfoSheet ac = new CustomerInfoSheet();
test.startTest();
ac.PrintOut=a.Id;
pageRef = ac.CustomerInfoSheet();
System.assertEquals(pageRef.getUrl(), '/'+a.Id);
test.stopTest();
}
}
All Answers
hi Cameron,
kindly provide the class as well