+ Start a Discussion
Scott M - SFDC FanScott M - SFDC Fan 

Have no clue how to make a test class


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) 

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


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.:(