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
sk aleemsk aleem 

Test class on extension controller while i test i got below error.plz some fix it

Thanks Mahesh D but i got error
in Meeting__c object i create a validation rule if Purpose__c is picklist field is 'New Business' or 'Modification' then Outcome__c field (currency) and Expected_Closed_Date__c field(Date) should not blank

test cllass
@istest
public class meetingOverviewFormControllerTest {
   static testMethod void testMethod1(){        
    Account acc=new Account(Name='TestMethod');
     insert acc;
     Opportunity opp=new Opportunity(Name='TestOpp',StageName='Closed Won',CloseDate=system.today());
    insert opp;
       Meeting__c mRec = new Meeting__c(Purpose__c = 'New Business',Outcome__c = 20000,Expected_Closed_Date__c = system.today(), Outcome_Flag__c = true,Opportunity__c = opp.Id,Account__c = acc.Id );
     insert mRec ;
      
       system.debug('meeting rec----->'+mRec);
    Test.StartTest();
          ApexPages.StandardController sc = new ApexPages.StandardController(acc);

            meetingOverviewFormController testAccPlan = new meetingOverviewFormController(sc);

            PageReference pageRef = Page.MeetingOverviewForm;
            pageRef.getParameters().put('id', String.valueOf(acc.Id));

            Test.setCurrentPage(pageRef);

            testAccPlan.FeedbackRadio=true;

            testAccPlan.submit();

       Test.StopTest();

    }

}

error:

rt failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Outcome and Expected Closed Date fields should not blank if the Purpose values New Business or Modification: []

 
Naval Sharma4Naval Sharma4
Hi SK,

It seems that your validation rules is not correct. Can you put you validation rule critieria here.

Thanks