You need to sign in to do that
Don't have an account?
Test Coverage:
HI all,
Hi need to test coverage for the apex class ,I am getting 66%, can any one help to get more that 75%, My apex class is
public class acceptavailability
{
id i;
id pid;
public acceptavailability()
{
i=apexpages.currentpage().getparameters().get('id');
system.debug('i===='+i);
for(Availability_In_Order__c a:[select id,Purchase_Order__c from Availability_In_Order__c where id=:i])
{
pid=a.Purchase_Order__c;
system.debug('+++'+pid);
}
}
public pagereference update1()
{
pagereference p2=new pagereference('/'+i);
purchase_order__C p=[select id,Available_Order_Accepted_by_executive__c from purchase_order__C where id=:pid];
system.debug('p===='+p.id);
p.Available_Order_Accepted_by_executive__c=true;
update p;
return p2;
}
}
_----------------------
My test class is
@isTest
Private class Testacceptavailability
{
static TestMethod void TestAccept()
{
id i ='a07U000000AK8mW';
id pid;
Purchase_Order__c p = new Purchase_Order__c();
insert p;
Availability_In_Order__c a= New Availability_In_Order__c(Purchase_Order__c=p.id );
insert a;
acceptavailability ac= new acceptavailability();
ac.update1();
}
}
The red lines are not covered any can help
Hi,
You can try the below code,
@isTest
Private class Testacceptavailability
{
static TestMethod void TestAccept()
{
Purchase_Order__c p = new Purchase_Order__c();
insert p;
Availability_In_Order__c a= New Availability_In_Order__c(Purchase_Order__c=p.id );
insert a;
ApexPages.Currentpage().getParameters().put('id',a.ID);
acceptavailability ac= new acceptavailability();
ac.update1();
}
}
All Answers
Hi,
You can try the below code,
@isTest
Private class Testacceptavailability
{
static TestMethod void TestAccept()
{
Purchase_Order__c p = new Purchase_Order__c();
insert p;
Availability_In_Order__c a= New Availability_In_Order__c(Purchase_Order__c=p.id );
insert a;
ApexPages.Currentpage().getParameters().put('id',a.ID);
acceptavailability ac= new acceptavailability();
ac.update1();
}
}
Thanks prakash. Now I got !00%