
Simply create an instance of inner class and populate its properties by test data: OuterClass.ExistingAccountResult result = new OuterClass.ExistingAccountResult (); result.salesforceaccountid = // testId result.status = // testStatus result.includeinfunnel = // testData result.masterid = // testId result.accountid = // testId Share
Table of Contents
When to use inner classes in Salesforce apex?
Apex inner classes offer up a huge number of use cases. For the most part you could use an outer class in their place but sometimes that can be overkill. I’ve personally used Apex inner classes for the following scenarios. Let’s say you want to send some record information back to an lwc.
What are the problems with Test class in Salesforce?
1 Regarding Test Class in Salesforces Related 8 JSON and escaped double quote 12 Comparison fails when converting Opportunity from/to JSON 2 Filter and search is not working 1 Code Coverage to Test Custom Object Public List 1 turn an APEX trigger into scheduled batch update
How to call the inner class method in apex?
however, if in apex by default the inner class is not the static one then no doubt as per the object oriented principle we can call the inner method using below syntax: oi.show (); // calling of Inner class method.
Is it possible to instantiate an object from an inner class?
In Apex there are no calss modifiers applicable on inner classes. Hence you can access inner class like static classes and still instantiate objects. In addition, only one level of class nesting is allowed unlike Java.