You need to sign in to do that
Don't have an account?
Scott 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.
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'; } } }
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.
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