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
PRASENJIT BANERJEE 24PRASENJIT BANERJEE 24 

Can someone help me to write Test Class for aura enabled Apex class ??

public with sharing class  AccountTeamMemberController 
{
    @AuraEnabled
    public static list<Account_Team_Member__c> getRelatedList(Id recordId)
        {
            Apttus__APTS_Agreement__c objAgreement = [Select id , Apttus__Account__c from Apttus__APTS_Agreement__c where id =: recordId ];
            List<Account_Team_Member__c> atmlist = [Select Name, Role__c, Active__c,Email__c from Account_Team_Member__c 
                                                    where Account__c =: objAgreement.Apttus__Account__c AND Role__c ='Relationship Manager'];
             return atmlist;
           
        }
}
Best Answer chosen by PRASENJIT BANERJEE 24
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Prasenjit,

The test class can be something as below. You should give all the mandotaty fields in all the respective objects while creating them.
 
@istest
public class AccountTeamMemberControllerTest {
static testmethod void methTest(){
    Account Acc= new Account();
    Acc.Name='Sample';
    insert acc;
   Apttus__APTS_Agreement__c  agg= new Apttus__APTS_Agreement__c ();
    agg.name='sample agreement';
    agg.Apttus__Account__c = acc.id;
    insert agg;
    Account_Team_Member__c  acm= new Account_Team_Member__c ();
    acm.Name='samplemember';
    acm.Role__c='Relationship Manager';
    acm.Active=true;
    acm.Email__c='sample@gmail.com';
    acm.Account__c= acc.id;
    insert acm;
    AccountTeamMemberController.getRelatedList(agg.id);
}

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,