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
sfdc development hintssfdc development hints 

H

i , can anyone help me writing a test class for below class

 

 

global class my_case_extensions
 {   
    webservice static void closedcase(ID CaseId)
    {
        List<Case> list_Case = [Select Id,Status from Case where Id=: CaseId];
        
        if(!list_Case.isEmpty())
        {
            list_Case[0].Status = 'Closed';
            update list_Case;
        }
    }
   
}

Best Answer chosen by Admin (Salesforce Developers) 
Alok_NagarroAlok_Nagarro

Hi,

 

Try the following code:

 

@isTest

class SampleClass

{

 

public static tesMethod void sampleMethod()

{

Case c=new Case(Status='New',Origin='Email');

insert c;

Test.startTest();

my_case_extensions.closedcase(c.id);

Test.stopTest();

}

 

}

All Answers

Alok_NagarroAlok_Nagarro

Hi,

 

Try the following code:

 

@isTest

class SampleClass

{

 

public static tesMethod void sampleMethod()

{

Case c=new Case(Status='New',Origin='Email');

insert c;

Test.startTest();

my_case_extensions.closedcase(c.id);

Test.stopTest();

}

 

}

This was selected as the best answer
sfdc development hintssfdc development hints

Thanks..