You need to sign in to do that
Don't have an account?
Lourdes Montero
write a test class that gets a Flow.Interview
I have created a Flow that creates a "quick case". I have a VisualForce page that has a "Quick_Case" apex class as a controller that gets the Flow and returns the landing page once the case is submitted.The problem is that I am trying to deploy this in production, but I need code coverage for the apex class.
Visualforce Page:
Apex Class:
I just do not know how to make the test class in this situation. I appreciate any help.
Visualforce Page:
<apex:page controller="Quick_Case" > <flow:interview name="Quick_Case" interview="{!flowInstance}" finishLocation="{!FinishLocation}" buttonLocation="bottom"> <apex:param name="Role" value="{!$User.UserRoleId}"/> <apex:param name="Department" value="{!$User.Department}"/> <apex:param name="CurrUserID" value="{!$User.Id}"/> </flow:interview>
Apex Class:
public class Quick_Case { Public Flow.Interview.Quick_Case flowInstance{get; set;} Public PageReference getFinishLocation(){ String ID = ''; if(flowInstance != null) ID = flowInstance.caseid; PageReference send = new PageReference('/' + ID); send.setRedirect(true); return send; }}
I just do not know how to make the test class in this situation. I appreciate any help.
Andy Boettcher
The kicker is that Flow requires user intervention, so it becomes a challenge to run via Unit Test. You may want to refactor your code a bit so you can set the "Id" variable via your Unit Test, as well as instanciate "flowInstance" to bypass line 8.