You need to sign in to do that
Don't have an account?
dhruv arora
help me in writting test class for this
public class abcd{
public FA_Attestation__c att{set;get;}
ApexPages.StandardController std;
public boolean flag {get;set;}
public id UserCheck {get;set;}
public boolean flag1 {get;set;}
public abcd(ApexPages.StandardController FAA2)
{
att = (FA_Attestation__c)FAA2.getRecord();
flag1 = false;
if(att.Confirmation__c == true)
{
flag = true;
}
//att = new FA_Attestation__c();
//std = FAA2;
}
public void saveform()
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please Check the Are you sure you want to submit the form? ' );
ApexPages.Message myMsg1 = new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter your signature in User Name field' );
UserCheck = att.user_name__c;
if(att.Confirmation__c == false && UserCheck == null)
{
ApexPages.addMessage(myMsg);
ApexPages.addMessage(myMsg1);
}
else if (att.Confirmation__c == false)
{
ApexPages.addMessage(myMsg);
}
else if (UserCheck == null)
{
ApexPages.addMessage(myMsg1);
}
else
{
if(flag1 == false)
{
update att;
}
flag1 = true;
flag = true;
// std.save();
}
}
}
public FA_Attestation__c att{set;get;}
ApexPages.StandardController std;
public boolean flag {get;set;}
public id UserCheck {get;set;}
public boolean flag1 {get;set;}
public abcd(ApexPages.StandardController FAA2)
{
att = (FA_Attestation__c)FAA2.getRecord();
flag1 = false;
if(att.Confirmation__c == true)
{
flag = true;
}
//att = new FA_Attestation__c();
//std = FAA2;
}
public void saveform()
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please Check the Are you sure you want to submit the form? ' );
ApexPages.Message myMsg1 = new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter your signature in User Name field' );
UserCheck = att.user_name__c;
if(att.Confirmation__c == false && UserCheck == null)
{
ApexPages.addMessage(myMsg);
ApexPages.addMessage(myMsg1);
}
else if (att.Confirmation__c == false)
{
ApexPages.addMessage(myMsg);
}
else if (UserCheck == null)
{
ApexPages.addMessage(myMsg1);
}
else
{
if(flag1 == false)
{
update att;
}
flag1 = true;
flag = true;
// std.save();
}
}
}
Make a register and assign that register to your stndr controller then run the methods in your controller and that's it.
I have this example:
This is just a part of my code, try to adapt it to yours
- Set up some data for the controller to access (in this case it looks like A_Attestation__crecords)
- Instantiate the standardController -
- Execute a method/methods
- Verify the behaviour with asserts.
The fact that the class is used as a controller is fairly immaterial.
Please try below code as sample code
Let us know if this will help you