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
Scott M - SFDC FanScott M - SFDC Fan 

Have no clue how to make a test class

Hi,

I am admittedly a beginner and have somehow made a working class to support a visual force page with some logic. Now I need to move it to production, but have no idea how to make a test class for it. I hope someone can help. Here is the code.

public class Parts_Order_Extention {


    public static List<ProcessInstance> approval = Null;
    
    public Parts_Order_Extention(ApexPages.StandardController stdController){
        
        Parts_Orders__c partsOrder = (Parts_Orders__c)stdController.getRecord();
          
        approval = [SELECT ID,Status, TargetObjectID 
                    FROM ProcessInstance
                    WHERE TargetObjectID= :partsOrder.Id];
        
    }
        
    public String getGridName() {
        
       if (!approval.isEmpty() && approval[0].Status == 'Pending'){
         
           return 'Line Items RO';
           
       } else {
            
           return 'Line Items';
             
       }
     
    }

}

 
NehalNehal (Salesforce Developers) 
Hi,

Please refer to below links that will help you on how to write test class;

1.http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_example.htm
2.http://blog.shivanathd.com/2013/11/Best-Practices-Test-Class-in-Salesforce.html
3.https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
4.http://salesforce.stackexchange.com/questions/21707/writing-test-classes-for-a-custom-controller
5.http://www.sfdc99.com/2013/05/14/how-to-write-a-test-class/
6.http://stackoverflow.com/questions/6861163/how-could-you-write-a-salesforce-test-class-for-a-simple-user-agent-lookup

I hope this helps.

Please mark this as a "Best Answer" if this has resolved your issue.
Scott M - SFDC FanScott M - SFDC Fan
Thanks for that.

I've actually successfully written a couple of test classes for triggers and I've tried some of the stuff from this page. https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

But, nothing I seem to do gets any code coverage.:(

Scott