Salesforce 설정(Setup)의 "Estimate your organization's code coverage" 링크는 Apex 코드 적용 범위를 추정해서 보여 주지만 100% 정확하지는 않습니다. 이 문서는 Apex Test Execution 도구와 Tooling API를 사용해 조직의 코드 적용 범위를 신뢰할 수 있게 계산하는 방법을 설명합니다.
Apex 코드 적용 범위는 Apex 코드의 여러 줄 중 테스트 클래스가 실행하는 줄의 비율을 나타냅니다. Salesforce에서 Apex를 프로덕션에 배포하려면 전체 코드 적용 범위가 75% 이상이어야 합니다.
정확한 코드 적용 범위 결과가 필요할 때마다 다음 단계를 따르십시오.
모든 테스트가 완료되면 조직의 전체 코드 적용 범위를 확인합니다.
쿼리 1 — 특정 Apex 클래스 또는 트리거에서 적용된 줄 수: ApexClassOrTriggerId로 필터링하여 ApexCodeCoverage 객체를 조회합니다. ID는 사용자의 15자리 또는 18자리 Apex 클래스/트리거 ID로 바꾸십시오. 결과에는 NumLinesCovered와 NumLinesUncovered 필드가 반환됩니다.
쿼리 2 — 클래스 또는 트리거에서 적용된 구체적인 줄: ApexClassOrTriggerId로 필터링하여 ApexCodeCoverage 객체의 Coverage 필드를 조회합니다. ID는 실제 클래스/트리거 ID로 바꾸십시오.
쿼리 3 — 조직 전체의 현재 코드 적용 범위 비율: ApexOrgWideCoverage 객체에서 PercentCovered 필드를 조회합니다. 조직 전체의 코드 적용 범위 비율이 반환됩니다.
Workbench에서 쿼리 실행: Workbench(workbench.developerforce.com)에서 Tooling API 쿼리를 테스트할 수 있습니다. Utilities > REST Explorer 로 이동해 GET 을 선택하고 URL에 /services/data/v29.0/tooling/query/?q=YOUR_QUERY 를 입력합니다. YOUR_QUERY 는 SOQL 문으로 바꾸고 Show Raw Response 를 클릭합니다.
적용 범위가 여전히 걱정된다면 배포 도구에서 Validate Only 버튼을 클릭해 프로덕션 유효성 검사를 수행하십시오. 적용 범위가 부족한 클래스가 있으면 도구가 오류 또는 경고를 표시합니다.
000386327

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.