Inserting person accounts in test mode
Hello My envrionment is using personAccounts. While I was developing my code I was running a testing method so my code will insert a person account. To my surprise, under this testing process after the insert command was applied, the respective inserted record showed an ID but the isPersonAccont value was FALSE. not only that, the record type was giving a null value and this was properly assigned using the command
RecordType personAccountRecordType = [SELECT Id FROM RecordType WHERE Name = 'Person Account' and SObjectType = 'Account'];
If I run the same code out of the testing environment then that record is properly inserted in the database with the mentioned fields isPersonAccount and RecordType assigned to their proper values (true and 'person Account' respectively). Any solution to have this working as expected in testing environment?
Thanks Jose
Account personAccount = new Account(FirstName = 'TestFirst', LastName = 'TestLast');