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
satya G 4satya G 4 

Hi,How to pass -ve values in test class,"getParentId()" this is another method with parameter and this method is assigned to "parent variable" and check with -ve values

,here is my code :Integer parent= getParentId(s.Forum_Year__r.Year__c ,auth.getAccessToken(),auth);
                if (!(parent>0))
                    throw new WordpressException('Parent does not exist');
                
                obj.parent=parent ;
                if (!String.isEmpty(s.Session_Type__c)) {
                    Integer etype= lookupEvent(s.Session_Type__c,auth.getAccessToken(), auth);
                    List<Integer> evlst=new List<Integer>();
                    evlst.add(etype);
                    obj.event_type=evlst;
                }
saikrishna.Gsaikrishna.G

Hi satya,

If this is integration try to build the body for JSON format in test am implement the method WebServiceMock 

see this link :

https://developer.salesforce.com/blogs/developer-relations/2013/03/testing-apex-callouts-using-httpcalloutmock.html

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex_testing.htm

satya G 4satya G 4
Yeah,This class is REST based ,i created mockresponse for this class,but in the first method above code is not covered..,so how to pass the -ve values in test class.,i mean how to cover the if condition.


Thank you
saikrishna.Gsaikrishna.G

Hi satya h

are you getting the values for getParentId() ? if not pass some dummy values to this method by calling this method