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
GuptaGupta 

How to cover these line in test class.

 If(feedbackRecord.Flexible__c == null ){
            
            feedbackRecord.Flexible__c.adderror('Enter value');
            return null;
            }
            
            If(feedbackRecord.Responsive__c == null ){
            
            feedbackRecord.Responsive__c.adderror('Enter value');
            return null;
            }
            
            If(feedbackRecord.Helpful__c == null ){
            
            feedbackRecord.Helpful__c.adderror('Enter value');
            return null;
            }

 

vbsvbs

Gupta - Ensure that there are 3 test data scenarios each where each of the fields does not have a value. If this code is part of a controller then you can confirm the following in the test class code:

system.assertEquals(true, ApexPages.hasMessages());

 To confirm the error text you can use:

system.assertEquals('Enter value', ApexPages.getMessages()[0]);