You need to sign in to do that
Don't have an account?
Improvement of Test Case
Hi to all,
Can any one Help to increase the code coverage @ present i am getting 75% .
Code in not covered in Red Part .
So please help regarding this part.
Apex Class:
Test Case:
@isTest
private class Dev_Package_RNController_Test{
static testmethod void testPackageController()
{
ApexPages.StandardController con = new ApexPages.StandardController(new rn__c());
Dev_Package_RNController Control = new Dev_Package_RnController(con);
control.getname();
control.getRN();
control.getRNpli();
Dev_Package_RNController Control1 = new Dev_Package_RnController(con);
}
}
Hello,
Just add this line:
Dev_Package_RNController obj = new Dev_Package_RNController();
Regards,
PP
Although adding the line:
Dev_Package_RNController obj = new Dev_Package_RNController();
will call the appropiate section of code, there is more you need to add to your code. Essentially what you have to remember first of all is that when writing test code you should never assume that there is data in your database. So you should create a RN__c and RN_Payment_Line_Item__c and insert them into the database. So you should add the following:
RN__c RN1 = new RN__c(field1Name=field1Value, etc);
RN_Payment_Line_Item__c RNPLI1 = new RM_Payment_Line_Item__c(some list);
insert RN1;
insert RNPLI1;
In addition your code calls ApexPages.currentPage().getParameters().get('id') so you need to set the current page of reference. For this you could use the following:
PageReference pageRef = new PageReference('/apex/myPage?id='+ RN1.id);
Test.setCurrentPageReference(pageRef);
Finally, it is good practice to assert that your code performed as desired with something like:
system.assertEquals (value1, value2);
So putting it all together your code should look something like:
Obviously there are some values to change and I will leave it to you to finish the assert statements, but I hope this helps.
You are creating instance of other constructor
Your test method should be like this