Testing, Debugging and Deployment Flashcards
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?
A. Create test classes to exercise the Visualforce page markup.
B. Select Fast Deployment to bypass running all the tests.
C. Select ‘Disable Parallel Apex Testing’ to run all the tests.
D. Add test methods to existing test classes from previous deployments.
D. 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 accurate statement about creating unit tests in Apex?
A. Increased test coverage requires large test classes with many lines of code in one method.
B. Triggers do not require any unit tests in order for you to deploy them from sandbox to production.
C. Unit tests with multiple methods result in all methods failing when one method fails.
D. System assert statements that do not increase code coverage contribute important feedback in unit tests.
D. System assert statements that do not increase code coverage, but contribute with an important feedback in unit tests.
Tests should assert your application’s behavior to ensure quality of code and verify expected results.
What is the proper process for an Apex unit test?
A. Create data for testing. Call the method being tested. Verify that the results are correct.
B. Query for test data using SeeAllData=true. Call the method being tested. Verify that the results are correct.
C. Create data for testing. Execute runAllTests(). Verify that the results are correct.
D. Query for test data using SeeAllData=true. Execute runAllTests(). Verify that the results are correct.
A. Create data for testing. Call the method being tested. Verify that the results are correct.
Creating your own data makes the method independent of the data in your org. Doing this helps to avoid errors when moving your code from one org to another. To verify that the method works as expected, call it using different inputs based on the data that was created.
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? (Select three answers.)
A. Test.setCurrentPage(pageRef);
B. String nextPage = controller.save().getUrl();
C. ApexPages.currentPage().getParameters().put(‘input’, ‘TestValue’);
D. public ExtendedController(ApexPages.StandardController cntrl) { }
A. Test.setCurrentPage(pageRef);
B. String nextPage = controller.save().getUrl();
C. ApexPages.currentPage().getParameters().put(‘input’, ‘TestValue’);
You need to set the current page to make sure you get the initial URL parameter.
This statement instantiates a new controller with all parameters in the page.
This line is 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? (Select two answers.)
A. Create a method that creates valid account records, and call this method from within test methods.
B. Create a method that queries for valid account records, and call this method from within test methods.
C. Create a method that loads valid account records from a static resource, and call this method within test methods.
D. Create a method that performs a callout for a valid account record, and call this method from within test methods.
A. Create a method that creates valid account records, and call this method from within test methods.
C. Create a method that loads valid account records from a static resource, and call this method within test methods.
In test classes, the developer needs to first create/populate the test records.
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? (Select two answers.)
A. Test menu in the Developer Console
B. Run Tests menu page in Salesforce Setup
C. REST API and ApexTestRun method
D. Apex Test Execution page in Salesforce Setup
A. Test menu in the Developer Console
D. Apex Test Execution page in Salesforce Setup
In the Developer Console, you can execute some or all tests in specific test classes, set up and run test suites, or run all tests.
You can run unit tests on the Apex Test Execution page. The Apex Test Execution page refreshes the status of a test and displays the results after the test completes.
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-wide defaults and sharing settings for the user who executes the code in the Salesforce organization?
A. Apex controllers
B. Apex triggers
C. Anonymous blocks
D. HTTP callouts
C. Anonymous blocks
Anonymous blocks can execute existing Apex classes, not merely lines of code written in the anonymous block window. Anonymous blocks execute using the full permissions of the current user.̀
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 attribute 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
True or False: Loading test data in place of user input for Flows is valid for execution by unit tests.
True
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?
A. Select the Override Log Triggers checkbox for the trigger.
B. Open the Progress tab in the Developer Console.
C. Open the Logs tab in the Developer Console.
D. Add the user name in the Log Inspector.
C. Open the Logs tab in the Developer Console.
Use the Logs tab in the Developer Console to open debug logs.
Which two types of information does the Checkpoints tab in the Developer Console provide? (Select two answers.)
A. Namespace
B. Exception
C. Time
D. Debug statement
A. Namespace
C. 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, date and time of the package containing the checkpoint.
What are two valid source and destination pairs that can send or receive change sets? (Select two answers.)
A. Developer Edition sandbox to sandbox
B. Sandbox to production
C. Developer edition org to production
D. Sandbox to sandbox
B. Sandbox to production
D. Sandbox to sandbox
Sandbox to production, production to sandbox, and sandbox to sandbox are all allowed as long as the developer creates sandboxes from the same production org and configures the orgs to accept incoming change sets.
Which two components can you deploy using Metadata API? (Select two answers.)
A. Console Layout
B. Account Layout
C. Case Feed Layout
D. Case Layout
B. Account Layout
D. Case Layout
You can deploy the Account and Case Layouts using the Metadata API.
Which two answers are true for a partial sandbox but do not apply to a full sandbox? (Select two answers.)
A. More frequent refreshes
B. Use of change sets
C. Limited to 5 GB of data
D. Only includes necessary metadata
A. More frequent refreshes
C. Limited to 5 GB of data
Partial sandboxes refresh every 5 days, while full sandboxes refresh every 29 days.
Partial sandboxes have a data storage limit of 5 GB, while full sandboxes match the production org.