You need to sign in to do that
Don't have an account?
Charles McDowell
Can anyone tell me why record will not load
I have an issue. the select statement returns no rows. If I put in the Query Editor it works fine. Help!!!
@isTest
Static void UpdateInvoice_Test(){
Try {
Usage__c u = [Select BillingDate__c, InternetUsage__c, MobileUsage__c From Usage__c Where Id = 'a0B1500000tQ8beEAC'];
u.BillingDate__c = date.today();
u.InternetUsage__c = 300;
u.MobileUsage__c = 300;
update u;
}
@isTest
Static void UpdateInvoice_Test(){
Try {
Usage__c u = [Select BillingDate__c, InternetUsage__c, MobileUsage__c From Usage__c Where Id = 'a0B1500000tQ8beEAC'];
u.BillingDate__c = date.today();
u.InternetUsage__c = 300;
u.MobileUsage__c = 300;
update u;
}
To see actual data in test class you need to put @isTest(seealldata=true) before class name init, then your query will return data but it is not recommanded as when you deploy this test class to production and other sandbox the query always return no values as this Id a0B1500000tQ8beEAC is specific to current sanbox.
You must not use @isTest(seealldata=true) and create Usage__c record your test class like
Usage__c u = new Usage__c( BillingDate__c = date.today(),
InternetUsage__c = 300,
MobileUsage__c = 300,
);
Insert u;
//Then your udpate testing:
u.BillingDate__c = date.today();
u.InternetUsage__c = 300;
u.MobileUsage__c = 300;
update u;
Thanks