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
Firas Taamallah 12Firas Taamallah 12 

How to write test class for Enum class?

public enum XAP_DAO_DML_OperationTypeEnum {
	CREATE,     // Insert
	MODIFY,     // Update
	REMOVE,     // Delete
	RESTORE     // Undelete  
        
}
How to cover this class?
 
AbhishekAbhishek (Salesforce Developers) 
Hi Firas,
 
you have to use enum keyword in your declaration and then use curly braces to demarcate the list of possible values.
 
For example, the following code creates an enum called OrderType:

public enum OrderType{ Coop, Normal, Package, SubInvoicing }

 
By creating the enum OrderType, you have also created a new data type called OrderType. You can use this new data type as you might use any other data type.
 
For Example:

OrderType o = OrderType.Coop; OrderType m(Integer x, OrderType o){ if(o==OrderType.Normal) return o; //…. }

For further clarification, you can check the below blog too,

https://salesforcescool.blogspot.com/2018/10/enum-in-salesforce.html

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.
Firas Taamallah 12Firas Taamallah 12
No it doesn't work
AbhishekAbhishek (Salesforce Developers) 
Firas Can you let me how it didn't work like error something like that...,
Firas Taamallah 12Firas Taamallah 12
it doesn't cover the enum class 0%