You need to sign in to do that
Don't have an account?

urgent..Need test class for apex class?
Hi Iam new to witing test class any body help me out the test class for below class?
public class BadgeAssignmentReportController{ public string un { get; set; } public List<WorkBadge> badges { get; set; } public List<WorkBadge> listbadges{get; set;} public Boolean badgeListSize{get;set;} public boolean noBadgeMsg{get;set;} public String fromDate{get;set;} public String toDate{get;set;} public PageReference generateBadgeReport() { system.debug('-------------------------'+un); system.debug('-----------toDate--------------'+toDate); system.debug('-----------fromDate--------------'+fromDate); Date myfromDate; String[] tempStr = fromDate.split('/'); Integer m = Integer.valueOf(tempStr[0]); Integer d = Integer.valueOf(tempStr[1]); Integer y = Integer.valueOf(tempStr[2]); myfromDate= Date.newInstance(y,m,d); Date mytoDate; String[] tempStr1 = toDate.split('/'); Integer m1 = Integer.valueOf(tempStr1[0]); Integer d1 = Integer.valueOf(tempStr1[1]); Integer y1 = Integer.valueOf(tempStr1[2]); mytoDate = Date.newInstance(y1,m1,d1); system.debug('--------------myFromDate -----------'+myFromDate); system.debug('--------------myFromDate -----------'+mytoDate ); if(un == null || un=='--None--'){ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please Select a User')); } if(toDate == null){ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please Select To Date')); } if(fromDate ==null){ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please Select From Date')); } listbadges = new List<WorkBadge>(); listbadges=[select id,RecipientId,CreatedById,Definition.imageUrl,Definition.Description,CreatedDate from WorkBadge where RecipientId=:un and CreatedDate >=:myFromDate and CreatedDate <=:mytoDate]; // system.assertEquals(listbadges,null); badges =new List<WorkBadge>(); badges.addall(listbadges ); badgeListSize = badges.size()>0? true:false; noBadgeMsg = badges.size()==0? true:false; return null; } public List<selectoption> options=new List<selectoption>(); public List<selectoption> getPickvaluesTest() { //profile userProfile =[select id from profile where name ='Chatter Free User' limit 1]; if(options.size()>0){ options.clear(); } options.add(new selectoption('--None--','--None--')); for(User us:[select id,Name from User where isactive = true]) { options.add(new selectoption(us.id,us.Name)); } return options; }
Thanks,
Isha
Hi,
Use this, run this test class, then check the coverage, then modify it with your convenience
All Answers
Hi,
Go for this post , it will definetly helps you out
http://abhithetechknight.blogspot.in/2013/10/salesforce-test-class-basics.html
hi abhi thanks for your reply
I tried but i think some where i missed please send me the detail test class iam very new to coding please help me.
Hi,
Use this, run this test class, then check the coverage, then modify it with your convenience