You need to sign in to do that
Don't have an account?
Flow.Interview Test Class
I have controller to access variable from flow when I create test class code coverage is to low because the can not access variable from flow in test class.Can help me to improve this test class.
The controller:
public with sharing class MinisiteFlow_Controller {
public String returnURL = ApexPages.currentPage().getParameters().get('rurl');
public Flow.Interview.MinisitePart1_1 MiniSiteFlow{get;set;}
public String lzsite{get;set;}
public String firstname{get;set;}
public String lastname{get;set;}
public String email{get;set;}
public String phone{get;set;}
public String state{get;set;}
public String partner{get;set;}
public String activityid{get;set;}
public String customerid{get;set;}
public Id SNEID{get;set;}
public PageReference getEndPage() {
PageReference send = new PageReference('/apex/MinisiteFlow_LastStep');
if(MiniSiteFlow != null){
SNEID = MiniSiteFlow.SNEID;
lzsite = MiniSiteFlow.vEndPage;
firstname = MiniSiteFlow.vFirstName;
lastname = MiniSiteFlow.vLastName;
email = MiniSiteFlow.vLeadEmail;
phone = MiniSiteFlow.vPhone;
state = MiniSiteFlow.vState;
partner = MiniSiteFlow.vPartner;
activityid = MiniSiteFlow.vActivityId;
customerid = MiniSiteFlow.vCustomerID;
send.getParameters().put('rurl',EncodingUtil.urlEncode(returnURL==null?'':returnURL,'UTF-8'));
send.getParameters().put('firstname',EncodingUtil.urlEncode(firstname==null?'':firstname,'UTF-8'));
send.getParameters().put('lastname',EncodingUtil.urlEncode(lastname==null?'':lastname,'UTF-8'));
send.getParameters().put('email',EncodingUtil.urlEncode(email==null?'':email,'UTF-8'));
send.getParameters().put('phone',EncodingUtil.urlEncode(phone==null?'':phone,'UTF-8'));
send.getParameters().put('state',EncodingUtil.urlEncode(state==null?'':state,'UTF-8'));
send.getParameters().put('partner',EncodingUtil.urlEncode(partner==null?'':partner,'UTF-8'));
send.getParameters().put('activityid',EncodingUtil.urlEncode(activityid==null?'':activityid,'UTF-8'));
send.getParameters().put('customerid',EncodingUtil.urlEncode(customerid==null?'':customerid,'UTF-8'));
send.getParameters().put('lzsite',EncodingUtil.urlEncode(lzsite==null?'':lzsite,'UTF-8'));
send.getParameters().put('SNEID',EncodingUtil.urlEncode(SNEID==null?'':SNEID,'UTF-8'));
}
send.setRedirect(true);
return send;
}
}
The test class :
@isTest
private class MinisiteFlow_Controller_Test {
statictestMethodvoid myUnitTest(){
PageReference pageRef = Page.MinisiteFlow;
Test.setCurrentPage(pageRef);
Lead l = new Lead(Company = 'test1@test.com', FirstName = 'first1', LastName = 'last1');
insert l;
Id lid = l.Id;
ApexPages.currentPage().getParameters().put('rurl','/'+l.Id);
MinisiteFlow_Controller controller = new MinisiteFlow_Controller();
controller.getEndPage();
}
}
Hi
Could i know what is this Flow.Interview.MinisitePart1_1.
And expand it.
Regards,
Rajesh.
MinisitePart1_1 is an cloud-based workflow. And, Flow.Interview.MinisitePart1_1 refers to how we call the flow in a apex class.
Hi
As u said I did't get u and how ever try to create the instance for Flow.Interview.MinisitePart1_1 like u created in class
Flow.Interview.MinisitePart1_1 mtb;
and insert some values which are in class.i.e mtb.vFirstName='test'; remaining.
insert mtb;
Let me know once u got any issue.
Regards,
Rajesh.