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
EllaElla 

Write an Apex Test Class for my Apex Class

Hello,
I have the following apex class and I need to write a test apex class for it. I started writing it but the code coverage is 0% . I am new into this and I don't know how to write it - can somebody help me ? 

APEX Class : 
public class GetAccount {
    
    @AuraEnabled
    public static List<Account> getAccountList(String currentId){
        List<Account> lstAcc = new List<Account>();  
        lstAcc = [Select id,Has_Code_Red_Cases__c,Has_Critical_Situation_Request_Cases__c from Account where id =: currentId];
        return lstAcc;
    }
}
TEST APEX CLASS:

@isTest 
public class GetAccountTest 
{
static testMethod void testMethod1() 
            {
                           Account acc = new Account();
                           acc.Name = 'Test Account';
                           insert acc;         
            }
}
Best Answer chosen by Ella
CharuDuttCharuDutt
Hii Ella
Try The Below Test Class
Changes Are In Bold
You Have To Give The Refference If Your Class Name And Method Which You Want To Test
@isTest 
public class GetAccountTest 
{
static testMethod void testMethod1() 
            {
                           Account acc = new Account();
                           acc.Name = 'Test Account';
                           insert acc;     
                GetAccount.getAccountList(acc.id);
            }
}
Please Mark It As Best Answer If It Helps
Thank You!