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
Chandu007Chandu007 

how to write test class for empty class with single parameter and no constructor

public class Constant
    {  
        
         public static boolean recCheck = false;
        
    }
Best Answer chosen by Chandu007
Khan AnasKhan Anas (Salesforce Developers) 
Hi Chandu,

Greetings to you!

Apex class:
public class EmptyClass {

    public static boolean recCheck = false;
}

Your test class should be like below:
@isTest
public class Test_EmptyClass {
    
    static testMethod void test1() {
        Test.StartTest();
        	EmptyClass emt = new  EmptyClass();
        Test.StopTest();        
    }
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Chandu,

Greetings to you!

Apex class:
public class EmptyClass {

    public static boolean recCheck = false;
}

Your test class should be like below:
@isTest
public class Test_EmptyClass {
    
    static testMethod void test1() {
        Test.StartTest();
        	EmptyClass emt = new  EmptyClass();
        Test.StopTest();        
    }
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer
Ajay K DubediAjay K Dubedi
Hi Chandu,
You only need to create a Object of Constant class.

@isTest
public class Test_Constant {
    @isTest
     public  static void Test_Constant_method() {
        Test.StartTest();
            Constant Con = new  Constant();
        Test.StopTest();        
    }
}
Deepali KulshresthaDeepali Kulshrestha
Hi Chandu,
Greetings to you!

- Please use the below test class for your problem : -

@isTest
public class singleParameterTestClass {
    public static testMethod void testschedule() {
        Test.StartTest();
        Constant obj  = new Constant();
        Test.stopTest();
    }
}

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

Thanks and Regards,
Deepali Kulshrestha.
Chandu007Chandu007
Above all answers helped me and solved my problem. Thank you all for responding to my query.