You need to sign in to do that
Don't have an account?
sachitanand kumar
hi.. how i can got 75% code coverge in following apex class.currently i m able to cover only 68 % any body can help me
here is my apex class
and here is my current test class
public class wrapperexample2 { public wrapperexample2(ApexPages.StandardSetController controller) { } public List<Schema.contact> SList{get;set;} //this line was not cover in test class List<wrapper> WList=New List<wrapper>(); public List<wrapper> getLstwrapperstring() //this line was not cover in test class { slist=[SELECT Account_name__c,Name,Phone,Title,Email FROM Contact WHERE AccountId =:ApexPages.CurrentPage().GetParameters().Get('id')]; //this line was not cover in test class for(Integer i=0 ;i<SList.size();i++){ //this line was not cover in test class WList.add(New wrapper(SList[i].name,SList[i].Account_name__c,SList[i].phone,SList[i].Title,SList[i].Email)); //this line was not cover in test class } return WList; //this line was not cover in test class } public class wrapper { public string cid{get;set;} public string cName{get;set;} public string cPhone{get;set;} public string cTitle{get;set;} public string cEmail{get;set;} public wrapper(string cName,string cid,string cPhone,string cTitle,string cEmail) { this.cid=cid; this.cName=cName; this.cPhone=cPhone; this.cTitle=cTitle; this.cEmail=cEmail; } } }
and here is my current test class
@isTest public class contact_pdf_test { static testMethod void data1(){ List<contact> acc = new List<contact>(); contact a = New contact(); a.firstName = 'mycontact'; a.lastName = 'mycontact'; a.phone='124365'; a.Title='Customer'; a.Email ='test@gmail.com'; acc.add(a); insert acc; ApexPages.StandardSetController sac = new ApexPages.StandardSetController (acc); wrapperexample2 aop = new wrapperexample2(sac); test.startTest(); PageReference myVfPage = Page.contact_pdf; Test.setCurrentPage(myVfPage); String mycontact; String cid; String cPhone; String cTitle; String cEmail; wrapperexample2.wrapper sacc = new wrapperexample2.wrapper(mycontact,cid,cPhone,cTitle,cEmail); test.stopTest(); } }
You will get 100% covearge from this code please update values of list and also call your wrapper method;
try this code
If Information is informative please select my answer as best answer
All Answers
You will get 100% covearge from this code please update values of list and also call your wrapper method;
try this code
If Information is informative please select my answer as best answer
its realy work good. thanks for help