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
Sean M 3Sean M 3 

Test Class for Page Redirect Visualforce Page & Apex Class

Good afternoon,

I am using an Apex Class coupled with a visualforce page to redirect a user to a Case record created from a Flow, when the Flow ends.

Code below:
 
public class flowController{
  // Instanciate the Flow for use by the Controller - linked by VF interview attribute
  public Flow.Interview.QuickCase flowInstance {get;set;}

  // Set the page reference accessor methods
  public PageReference finishLocation {
    get {
      PageReference pageRef = new PageReference('/' + newRecordId);
      pageRef.setRedirect(true);
      return pageRef;
      
    }
 
  }

  // Set the accessor methods for the flow output variable
  public String newRecordId {
    get {
      String strTemp = '';

      if(flowInstance != null) {
        strTemp = string.valueOf(flowInstance.getVariableValue('CreatedCaseId'));
      }
      return strTemp;
    }

  set { newRecordId = value; }
  }
}

I am having trouble writing a Test Class for this. Can anyone give me a starting point?

Many thanks
Best Answer chosen by Sean M 3
devedeve
Hi Sean,

Please try this 

@isTest private class flowControllerTest {

    @isTest static void testfinishLocation() {
        flowController fc = new flowController();
        
        System.assertNotEquals(null, fc.finishLocation, 'test');
    }
}

All Answers

devedeve
Hi Sean,

Please try this 

@isTest private class flowControllerTest {

    @isTest static void testfinishLocation() {
        flowController fc = new flowController();
        
        System.assertNotEquals(null, fc.finishLocation, 'test');
    }
}
This was selected as the best answer
Sean M 3Sean M 3
Thank you deve, worked a treat.