2017-02-11 4 views
1

테스트 케이스에서 코드 적용 범위를 늘려야합니다. 지금은 약 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; 
    } 
} 

답변

0

초 @EricSSH에 대한 테스트 데이터가 표시되지 않는 데이터를 구축 - 당신은 당신의 테스트가 실제로 통해 실행되도록 할 수있어 일부 데이터를 작성하여 전체 코드를 작성하십시오. 다음 trailhead는 Apex 테스트에서 나에게 매우 도움이되었습니다.

https://trailhead.salesforce.com/modules/apex_testing