You need to sign in to do that
Don't have an account?
Marris
How to create person account in Test class
Hi
I had a query in my class stated like this
User user = select conatctid form User where id=:userinfo.getUserId();
Account acc = Select mailingcity,mailingstate from account where personconatctID=:user.contactId();
For this I have to write a test class. I dont know how to create a dummy person account and assign it to User for testing
I have to test by creating a new person account and user to test the above Query how can i do this?
Need a help on this....
Thanks
Marris.
Hi Marris.
This is the way you can create Person Account in SFDC test Class.
String RecTypeId= [select Id from RecordType where (Name='Person Account') and (SobjectType='Account')].Id;
Account Accnt = new Account(
RecordTypeID=RecTypeId,
FirstName=’Test FName’,
LastName=’Test LName’,
PersonMailingStreet=’test@yahoo.com’,
PersonMailingPostalCode=’12345’,
PersonMailingCity=’SFO’,
PersonEmail=’test@yahoo.com’,
PersonHomePhone=’1234567’,
PersonMobilePhone=’12345678’
);
insert newAccount;
But as see your code seems you are using partner User.
So need more code for that create a partner user in test class use RunAs() method in test class after that may be you will cover your test class successfully.
I can help you more if you put your complete code here.
Thanks
Onkar Kumar
Hi onkar
Thanks for the help. Below is my code. In that code I am trying to cover saveShipping method.