You need to sign in to do that
Don't have an account?
XIO
Assistance with Test Class - only 40% Code Coverage
Hi All,
I have a apex controller that I need to deploy into our production org. The current test class is only covering 40%. Any assistance is increasing the coverage for the controller below is much appreciated. Controller and test class below - thank you!!
Controller
I have a apex controller that I need to deploy into our production org. The current test class is only covering 40%. Any assistance is increasing the coverage for the controller below is much appreciated. Controller and test class below - thank you!!
Controller
public class AnnualTouchpointPlanningController { Public List<Task> TaskList{get;set;} // public String contId{get;set;} // public String dcid{get;set;} // public task task{get;set;} // Public string editid{get;set;} public opportunity oo; // public Id selectedDetailID { get;set; } String currentRecordId ; public AnnualTouchpointPlanningController(ApexPages.StandardController controller) { currentRecordId = ApexPages.CurrentPage().getparameters().get('id'); TaskList = [Select subject,id, Type, EarliestDate__c,Who.Type,whatID,priority,status,ActivityDate,ATP_Task__c,Completion_Date__c,Task_Record__c FROM Task WHERE Whatid=:currentRecordId and ATP_Task__c=true ]; if(TaskList.size() == 0) { Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No ATP Tasks to Display')); } } public pagereference saveProject(){ system.debug('ssssss'+TaskList ); upsert TaskList ; // the LIST PageReference pageRef = new PageReference('/apex/AnnualTouchpointPlanning'); pageRef.setRedirect(true); return null; } public PageReference save() { upsert TaskList ; return new PageReference('/apex/AnnualTouchpointPlanning'); } public pagereference deleteCon() { String s1 = System.CurrentPageReference().getParameters().get('dtlIdParam'); task t=[ select id,status From task Where id=:s1]; t.status= 'completed'; upsert t; PageReference pageRef = new PageReference('/apex/AnnualTouchpointPlanning'); pageRef.setRedirect(true); return null; } }Test Class
@isTest public class AnnualTouchpointPlanningController_UT { static testMethod void myTest() { Account a=new Account(); a.Name='test'; a.Type='Member'; a.Major_Market__c='Other'; a.AnnualRevenue=1000; a.Member_Services_Representative__c='00550000006Rkqu'; insert a; Service_Discipline__c sd=new Service_Discipline__c(); sd.Name='sd test'; sd.Service_Discipline_Acronym__c='test acc'; insert sd; Opportunity opp=new Opportunity(); opp.AccountID=a.Id; opp.Name='test'; opp.Type='New'; opp.Subscription_Start_Date__c = Date.today() + 1; opp.First_Service_Discipline__c=sd.Id; opp.Subscription_Expiration_Date__c = Date.today() + 30; opp.RecordTypeId='01250000000HjVK'; opp.Deal_Status__c='Budget Approved'; opp.StageName='PC - Pre-Contact'; opp.CloseDate= Date.today() + 45; opp.Amount = 500; insert opp; Task tsk = new Task(); tsk.WhatId = opp.Id; tsk.Subject = 'Test Subject'; tsk.Status = 'Completed'; tsk.ATP_Task__c = true; tsk.Type = 'Vision & Strategy Call (180)'; tsk.Priority = 'Normal'; tsk.ActivityDate = Date.today() + 30; insert tsk; delete tsk; PageReference pageRef = Page.AnnualTouchpointPlanning; Test.setCurrentPage(pageRef); pageRef.getParameters().put('id',opp.Id); ApexPages.StandardController sc = new ApexPages.StandardController(tsk); AnnualTouchpointPlanningController testAccPlan = new AnnualTouchpointPlanningController(sc); testAccPlan.save(); //testAccPlan.deleteCon(); // testAccPlan. } }
All Answers