2

i write a test class for the apex class which is based upon inserting the PersonAccount records.i try to insert a record using csv file in test class but i got a error at the time of ApexTestExecution.The Error is Validation Errors While Saving Record(s).This is my code...

@isTest
private class TestMyAccountServices {
  static testMethod void getAllServices() {

    List<sObject> ls = Test.loadData(Account.sObjectType,'TestResources'); 

    Account a = (Account)ls[0]; 
    System.assert(ls.size()==1);
    insert a;
    }
}

And the csv file columns are Firstname,Lastname,Recordtypeid(PersonAccoount recordtypeid)&Personemail. How to resolve this error?

  • whats the error thats coming?Also record type Id will vary from environment to environment hence i would advice not to keep in CSV .We can query and replace record typeId – Mohith Shrivastava Jan 20 '14 at 7:53
  • Thanks for your reply@MohithKumar The error is "Validation Errors While Saving Record(s)". Is there any other required fields for PersonAccounts,i added OwnerId,Ownership but it shows the same error. – Venkatsforce Jan 20 '14 at 7:57
  • Validation Errors means there is a custom validation rule in your org that's causing the issue.Please go through all validation rules on contact and Account and also the rule thats failing will be indicated in failure – Mohith Shrivastava Jan 20 '14 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.