+ Start a Discussion
Alan FloresAlan Flores 

Help with test class @AuraEnabled

Hello dear collages, I wan to know if someone can help me to create a test class for this apex code:

public class SP_AS
{
    @AuraEnabled
    public String recentMonthEndDate;
 
    Class HistoricalData{
        @AuraEnabled
        public String asOfDate;
       
        @AuraEnabled
        public Decimal marketValue;
    }
   
    public Class ClientAccountSummary{
        @AuraEnabled
        public String clientAccountName;
       
        @AuraEnabled
        public Decimal marketValue;
       
   }
   
}

I'm very new in salesforce and I don't have idea about how to do this. Thanks in advance.
 
Best Answer chosen by Alan Flores
DeveloperDeveloper
Hi Flores,

May I request you to please check for Test Class Generator App from APP Exchange.Please refer the below link.

https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EFozgUAD

I hope it will be helpful.

Please mark it as best answer if the information is informative.

Thanks & Regards 
Gopal M.


 

All Answers

Glyn Anderson 3Glyn Anderson 3
Alan, You don't really have any code to test.  You might check in Developer Console to see how many lines of code it thinks there are.  It might be zero.  If not, the code below should do the trick.  (Disclaimer: This code is untested and may contain typos.

<pre>
@isTest
private class SP_AS_Test
{
    static testMethod void test_SP_AS()
    {
        SP_AS sp_as = new SP_AS();
        SP_AS.HistoricalData = new SP_AS.HistoricalData();
        SP_AS.ClientAccountSummary = new SP_AS.ClientAccountSummary();
    }
}
</pre>
 
DeveloperDeveloper
Hi Flores,

May I request you to please check for Test Class Generator App from APP Exchange.Please refer the below link.

https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EFozgUAD

I hope it will be helpful.

Please mark it as best answer if the information is informative.

Thanks & Regards 
Gopal M.


 
This was selected as the best answer
Alan FloresAlan Flores
Thank you Gopal! The tool is very helpful!