+ Start a Discussion
Derek Davis 7Derek Davis 7 

New to APEX.... Class Working but Example/Explaination of Test Class Needed

Hi All - I am very familiar with Salesforce but newer to APEX. I recently created an APEX Class to change the behavior of a Flow Finish Button. When the finish button is clicked this class sets the URL and sets the referenced variables within the URL.

The class is working, but I'm not sure about how to go about creating the test coverage for the Class shown below. Any assistance would be appreciated!!

VF Page -
<apex:page Controller="OpptyFlowController" TabStyle="Opportunity">
    <flow:interview name="CreateOppty" interview="{!myflow}" finishlocation="{!OID}" />

Here is the Class -
public class OpptyFlowController {

public Flow.Interview.CreateOppty myFlow { get; set; }

public String getmyID() {
if (myFlow==null) return '';
else return myFlow.OpptyID;

public PageReference getOID(){
PageReference p = new PageReference('/apex/opportunityProductEntry?id=' + getmyID() + '&addTo=' + getmyID() + '&retURL=%2F006%2Fe&sfdc.override=1');
return p;

Best Answer chosen by Derek Davis 7
William TranWilliam Tran
Do you need a test class to get test coverage?  If so, just create a test class and call the methods such as getOID and getmyID.
If you don't get 100%, you will need to tweak it to get more coverage.

private class myflowTest 
    private static testMethod void Testflow() 
            OpptyFlowController sc = new OpptyFlowController();
        catch(Exception ee){    }   

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you.