You need to sign in to do that
Don't have an account?
Setting controller parameters in test class
Hi,
fromLogo and ToLogo are two lookup fields to account from a custom object (Account_Movement__c) in my VF page.
public with sharing class AccMvmtController
{
public AccMvmtController(ApexPages.standardController cont)
{
fromLogo=newAccount_Movement__c();
toLogo =newAccount_Movement__c();
isnotblank=
false;
}
public Account_Movement__c fromLogo {get;set;}
publicAccount_Movement__c toLogo {get;set;}
}
@istest
privatestaticvoidtestAccMvmtController()
{
System.runas(semiAdmin) {
Test.StartTest();
PageReference pageref = Page.CompanyMovement;
Test.setCurrentPage(pageRef);
Test.StopTest();
}
How to set parameters for fromLogo and ToLogo in my test class
Please suggest.
Thanks
Hi
Create an instance of that class inside test class, It will automatically cover , If not then do one thing
Assign that varibale with some hardcoded value
instance . variable = something which sholud be same type as variable ;
@istest
privatestaticvoidtestAccMvmtController()
{
System.runas(semiAdmin) {
Test.StartTest();
AccMvmtController clsInstance = AccMvmtController();
PageReference pageref = Page.CompanyMovement;
//optional ......You will try this If above trick does not work
Account_Movement__c testActMov = new Account_Movement__c( );
testActMov.someRequiredFied = 'something' ;
insert testActMov;
clsInstance .fromLogo = testActMov ;
Test.setCurrentPage(pageRef);
Test.StopTest();
}
Let me know It works or not
Did this post answers your Question,If so please mark it as Solved and hit kudos icon for this Post
Thanks
use this before Test.stoptest();
Maros
There are the way to set the values, if you are talking about get:
Then do this