Cert Prep: PD1: Testing, Debugging, & Deployment

Get a Refresh on Testing

Write and execute tests for triggers, controllers, classes, flows, and processes using various sources of test data.
  • A developer creates a new Visualforce page and Apex extension, and writes test classes that exercise 95% coverage of the new Apex extension. Change set deployment to production fails with the test coverage warning “Average test coverage across all Apex classes and triggers is 74%, at least 75% test coverage is required.” What can the developer do to successfully deploy the new Visualforce page and extension? Add test methods to existing test classes from previous deployments. This increases the code coverage on the rest of the Apex classes in the org.
  • Which is an accurage statement about creating unit tests in Apex? System assert statements that do not increase code coverage contribute important feedback in unit tests
  • What is the proper process for an Apex unit test? Create data for testing. Call the method being tested. Verify that the results are correct.
  • A developer has a single custom controller class that works with a Visualforce wizard to support creating and editing multiple sObjects. The wizard accepts data from user inputs across multiple Visualforce pages and from a parameter on the initial URL. Which three statements are necessary inside the unit test for the custom controller? Test.setCurrentPage(pageRef) - this sets the current page to make sure you get the initial URL parameter.
    String nextPage = controller.save().getUrl(); - This statement instantiates a new controller with all parameters in the page.
    ApexPages.currentPage().getParameters().put('input','TestValue'); - used to inject the query parameter ?input=TestValue in the URL for the page
  • An org has different Apex classes that provide account-related functionality. After a new validation rule is added to the Account object, many of the test methods fail. Which two actions will resolve the failures and reduce the number of code changes needed for future validation rules? Create a method that creates valid account records, and call this method from within test methods. Create a method that loads valid account records from a static resource, and call this method within test methods
  • When working in a sandbox environment, which two things should the developer use to verify the functionality of a new test class before the developer deploys that test class to production? Test menu in the Developer Console. Apex Test Execution page in Salesforce Setup.
  • A developer has a block of code that omits any statements that indicate whether the code block should execute with or without sharing. What will automatically obey the organization-side defaults and sharing settings for the user who executes the code in the Salesforce organization? Anonymous blocks

  • A developer creates an Apex class that has private methods. What can the developer do to ensure that the test class can access the private methods? Add the @TestVisible annotation to the methods
  • A developer needs to ensure there is sufficient test coverage for an Apex method that interacts with Accounts. The developer needs to create test data. What can the developer use to load this test data into Salesforce? Static resources
  • Loading test data in place of user input for flows is valid for execution by unit tests - true or false? True

Review Debugging and Deployment

Describe the environments, requirements and process for deploying code. Describe the Salesforce Developer tools such as Salesforce DX, Salesforce CLI, and Developer Console, and when to use them. Describe how to approach debugging system issues, monitoring flows, processes, and asynchronous and batch jobs.
  • A developer created an Apex trigger using the Developer Console and now wants to debug code. How can the developer accomplish this in the Developer Console? Open the Logs tab in the Developer Console
  • Which two types of information does the Checkpoints tab in the Developer Console provide? Namespace & Time: the checkpoints tab displays a list of saved checkpoints that preserve a snapshot of the state of objects in memory at the time the checkpoint was reached. Each checkpoint displays the namespace of the package containing the checkpoint.
  • What are two valid sources and destination pairs that can send or receive change sets? Sandbox to production, Sandbox to sandbox
  • Which two components can you deploy using Metadata API? Account Layout, Case Layout
  • Which two answers are true for a partial sandbox but do not apply to a full sandbox? More frequent refreshes, Limit to 5 GB of data

  • In which Salesforce environment can a developer build a managed package? Developer Edition
  • What is the minimum log level needed to see user-generated debug statements? Debug