function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to create person account in apex Test class



    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....




Rahul SharmaRahul Sharma

Marris, Hope this helps



Hi rahul sharma


       I can create a person account by this link Please help me on how to create a user for test class with person account id/person contact id to test the methods in the class .