+ Start a Discussion
bharath kuamarbharath kuamar 

I am getting the following test failure by running the test class

public class DonorProfileController
{
    public String contactId {get;set;}
    public Contact donorObj {get;set;}
    
    public DonorProfileController() {
        User oUser = [Select Id, ContactId From User Where Id=:UserInfo.getUserId()];
            contactId = oUser.contactId;
            donorObj = [Select FirstName,LastName,BirthDate,Description,Email,Phone,Mobilephone,Fax From Contact Where Id=:contactId];

    }
   
    public String firstname{ get; set; }
    
    public String lastname{ get; set; }
    
    public Date birthdate{ get; set; }

    public String description { get; set; }

    public String email { get; set; }

    public String phone { get; set; }

    public String homephone { get; set; }

    public String fax { get; set; }

    public String mobilephone { get; set; }

     public PageReference saveAction()
    {
    System.debug('saveAction()');
        
//        MyProfile__c profile=[Select Name,First_Name__c,BirthDate__c,Description__c,Fax__c,Email__c,Phone__c from MyProfile__c Where Id=:contactId ];
        MyProfile__c profile=new MyProfile__c();
        profile.Name = this.lastname;
        profile.First_Name__c = this.firstname;
        profile.BirthDate__c = this.birthdate;
        profile.Description__c=this.description;
        profile.Email__c=this.email;
        profile.Phone__c=this.phone;
        profile.Fax__c=this.fax;
        profile.Mobile__c=this.mobilephone;
        insert profile;
        return null;
        
      /*  Contact donorObj = [Select FirstName,LastName,BirthDate,Description,Email,Phone,Mobilephone,Fax From Contact Where Id=:profile.Id];
        donorObj.LastName = profile.Name;
        donorObj.FirstName = profile.First_Name__c;
        donorObj.BirthDate = profile.Birthdate__c;
        donorObj.Description=profile.Description__c;
        donorObj.Email=profile.Email__c;
        donorObj.Phone=profile.Phone__c;
        donorObj.Fax=profile.Fax__c;
        donorObj.Mobilephone=profile.Mobile__C;
        update donorObj;
        */
        
        
       }
           
          /*      
            if (pageRef == null) {
                pageRef = Page.DonorProfile;
            }
            pageRef.setRedirect(true);
            return pageRef;
            */
            
            
            //test methods written for the class DonorProfileController
            
                static testmethod void DonorProfileController()

    {
    DonorProfileController dd2 = new DonorProfileController();
        dd2.LastName ='test';
        dd2.FirstName = 'date';
        dd2.BirthDate = system.today();
        dd2.Description='description';
        dd2.Email='abc@abc.com';
        dd2.Phone='65662626';
        dd2.Fax='545454';
        dd2.Mobilephone='656562';
        dd2.saveAction();
    }
 
          
          
  
}

Class.DonorProfileController.<init>: line 9, column 1 Class.DonorProfileController.DonorProfileController: line 77, column 1

please help me out with my case