Find your content:

Search form

You are here

Test class for Visual Workflow


I have a flow, which shows a list of Opportunities, one by one based on score. This flow has been referenced in a Visualforce page:

   <apex:page controller="OppPriorityController">
    <h1>Opportunity Prioritisation Wokflow</h1>
    <flow:interview name="Opportunity_Prioritisation_Flow" interview="{!myflow}" buttonLocation="bottom">
     <apex:param name="varCurrentUserID" value="{!$User.Id}"/> 

The OppPriorityController is below:

    public class OppPriorityController {

    public Flow.Interview.Opportunity_Prioritisation_Flow myflow { get; set; }
    public String getPhoneNumber() {
             return myflow.PhoneNumber; 
    public String getAccountID() {
             return myflow.AccId;
     public String getAccountName() {
             return myflow.AccountName;
     public String getOpportunityID() {
             return myflow.OppId;
     public String getOpportunityName() {
             return myflow.OppName;

The test class which I tried is below:

    @isTest (SeeAllData=true)
private class OppPriorityControllerTest {
    public static testMethod void myTestMethodForFlow() {
        PageReference pageRef = Page.OppPriorityPage;
        OppPriorityController oppPriorityController = new OppPriorityController();        
        oppPriorityController.myflow = new Flow.Interview.Opportunity_Prioritisation_Flow(new Map<String, Object>());
        String pNumber = oppPriorityController.getPhoneNumber();
        String accountId = oppPriorityController.getAccountID() ;
        String accountName = oppPriorityController.getAccountName();
        String opportunityID = oppPriorityController.getOpportunityID();
        String opportunityName = oppPriorityController.getOpportunityName();

I received an exception: Interview not started.

Any help would be greatly appreciated.

Attribution to: goabhigo

Possible Suggestion/Solution #1

Right now there is no real way to test the controller. You would need an Apex API for Flow to do this, which I am told is something we are working on.

Attribution to: metadaddy

Possible Suggestion/Solution #2

If the goal is track how changes might effect the user flow - you might try a Selenium script with it:

Attribution to: joshbirk
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content