You need to sign in to do that
Don't have an account?
Sebastien Plante
Confused with test class... simple Apex code.
I got this simple code
and I want to make a test class
public class AccountShipTo { public Account originalAccount{get; set;} public list<Account> accnt {get;set;} public AccountShipTo (ApexPages.StandardController controller) { originalAccount = [SELECT Id, ParentId FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; accnt = new list<Account>(); accnt = [SELECT Id, Name, ShippingStreet,ShippingCity,ShippingState,ShippingCountry,ShippingPostalCode FROM Account WHERE ParentId = :originalAccount.Id AND ShippingStreet<>'']; } }
and I want to make a test class
@isTest(seealldata=true) public class AccountShipToTest { @isTest public static void testAccountShipTo(){ Account originalAccount = [Select Id from Account limit 1]; list<Account> accnt = [SELECT Id, Name, ShippingStreet,ShippingCity,ShippingState,ShippingCountry,ShippingPostalCode FROM Account WHERE ParentId = :originalAccount.Id AND ShippingStreet<>'']; } }
but I got 0% coverage... what do I miss?
Sorry, pretty new in this! :(
You can try this :
All Answers
You can try this :
Analyzing, you did add a "fake" ApexPage.StandardController and created two dumb account, just to be able to select them so the test could do something ?
So, as I understand, I'm better create data so the test can pull them and not try to use actual data ?