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
tina sharma 10tina sharma 10 

How to write test class code

I am new to writing test classes in salesforce.
I require urgent help.
I request some one to please let me know how to write 100% code coverage for the following apex class.

public with sharing class MyClass
{
    @AuraEnabled
    public static void storeSomeData(Object records){
       
         Cache.SessionPartition sessionPartition = Cache.Session.getPartition('local.OrgLinks1);
         try{
           Cache.Session.put('local.OrgLinks1.SomeData', records); 
         }
        catch(Exception e)
        {
            system.debug('cache failed');
        }      
     }
    
    @AuraEnabled
    public static Object getMyData(){
        
         Object someRecords;
        Cache.SessionPartition sessionPartition = Cache.Session.getPartition('local.OrgLinks1');
         try{
            if (sessionPartition.contains('SomeData')) {
                    someRecords= (Object)sessionPartition.get('SomeData');
           }
         }
        catch(Exception e)
        {
            system.debug('cache failed');
        }  
        return someRecords;
     }
}
}

Please let me know.
Thanks
Tina
SRKSRK

i will suggent what ever you have written so far as test class you should post that too 

@isTest

public class MyClassTestClass
{

static testMethod void testmethod1()
        {
Object  obj = MyClass.getMyData();

MyClass.storeSomeData(obj);

          }

}