테스트 케이스에서 코드 적용 범위를 늘려야합니다. 지금은 약 50 %입니다. 내 확장 기능은 계정이라는 것을 알고 있지만 어떻게 든 작업 정보와 Account.ParentId를 포함시켜야합니다! = Null 및 Task.Status = : '완료되었습니다'내 테스트 사례에 어떻게 든 ... 어떤 도움을 주시면 감사하겠습니다 ...Salesforce Standard Developer에서 코드 커버리지 향상 테스트 케이스
내 컨트롤러 :
public class childTaskOnParentCont {
public Account acc {get;set;}
public List<Task> tasks {get;set;}
public List<Task> closedTasks {get;set;}
public List<Task> tasksLimited {get;set;}
public List<Task> closedTasksLimited {get;set;}
public List<Contact> cons {get;set;}
//constructor
public childTaskOnParentCont(apexpages.StandardController con){
acc = (Account) con.getRecord();
cons=[SELECT id from Contact WHERE AccountID=: acc.Id];
tasksLimited= [Select whoid,whatid,subject,type, Medium_of_Activity__c, activitydate, lastmodifieddate,Account.Name,
ownerid, status, priority from Task
Where Account.ParentID != null And status !='completed' ORDER BY activitydate LIMIT 10];
system.debug('taskslimited: '+taskslimited);
closedTasksLimited= [Select whoid,subject,type, Medium_of_Activity__c, activitydate, lastmodifieddate,Account.Name,
ownerid, status, priority from Task
Where Account.ParentID != null And status =:'completed' ORDER BY activitydate LIMIT 10];
system.debug('closedTasksLimited: '+closedTasksLimited);
}
//Get the Account Information
public Account getAccount() {
return [SELECT id,ParentId, name FROM Account WHERE Id=: acc.Id];
}
//Get Open Tasks for Child Tasks
public List<Task> getTasks() {
tasks= [Select whoid,subject,type, activitydate, lastmodifieddate,Account.Name,
ownerid, status, priority from Task
Where Account.ParentID != null And status !='completed' ORDER BY activitydate];
return tasks;
}
//Get Closed Tasks for Child Tasks
public List<Task> getClosedTasks() {
closedTasks= [Select whoid,subject,type, activitydate, lastmodifieddate,Account.Name,
ownerid, status, priority from Task
Where Account.ParentID != null And status =:'completed' ORDER BY activitydate];
return closedTasks;
}
}
My Test Case:
public class childTaskOnParentCont {
public Account acc {get;set;}
public List<Task> tasks {get;set;}
public List<Task> closedTasks {get;set;}
public List<Task> tasksLimited {get;set;}
public List<Task> closedTasksLimited {get;set;}
public List<Contact> cons {get;set;}
//constructor
public childTaskOnParentCont(apexpages.StandardController con){
acc = (Account) con.getRecord();
cons=[SELECT id from Contact WHERE AccountID=: acc.Id];
tasksLimited= [Select whoid,whatid,subject,type, Medium_of_Activity__c, activitydate, lastmodifieddate,Account.Name,
ownerid, status, priority from Task
Where Account.ParentID != null And status !='completed' ORDER BY activitydate LIMIT 10];
system.debug('taskslimited: '+taskslimited);
closedTasksLimited= [Select whoid,subject,type, Medium_of_Activity__c, activitydate, lastmodifieddate,Account.Name,
ownerid, status, priority from Task
Where Account.ParentID != null And status =:'completed' ORDER BY activitydate LIMIT 10];
system.debug('closedTasksLimited: '+closedTasksLimited);
}
//Get the Account Information
public Account getAccount() {
return [SELECT id,ParentId, name FROM Account WHERE Id=: acc.Id];
}
//Get Open Tasks for Child Tasks
public List<Task> getTasks() {
tasks= [Select whoid,subject,type, activitydate, lastmodifieddate,Account.Name,
ownerid, status, priority from Task
Where Account.ParentID != null And status !='completed' ORDER BY activitydate];
return tasks;
}
//Get Closed Tasks for Child Tasks
public List<Task> getClosedTasks() {
closedTasks= [Select whoid,subject,type, activitydate, lastmodifieddate,Account.Name,
ownerid, status, priority from Task
Where Account.ParentID != null And status =:'completed' ORDER BY activitydate];
return closedTasks;
}
}