Testing, Debugging and Deployment Flashcards

1
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

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.̀

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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?

A

Add the @TestVisible attribute to the methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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?

A

Static resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

True or False: Loading test data in place of user input for Flows is valid for execution by unit tests.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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.

A

C. Open the Logs tab in the Developer Console.

Use the Logs tab in the Developer Console to open debug logs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

B. Account Layout

D. Case Layout

You can deploy the Account and Case Layouts using the Metadata API.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In which Salesforce environment can a developer build a managed package?

A

Developer Edition

17
Q

What is the minimum log level needed to see user-generated debug statements?

A

DEBUG

18
Q

What is true regarding running tests from the Salesforce UI? Choose 2 answers.

A. All classes can be selected

B. Individual classes can be selected

C. After tests are run, code coverage is available on Apex Test Execution page

D. After test classes are selected, they are placed in the Apex Job queue and will always run in parallel

A

A. All classes can be selected

B. Individual classes can be selected

19
Q

What is true regarding the testing framework? Choose 3 answers

A. Records inserted by unit tests must be deleted

B. Unit tests cannot send outbound email

C. Unit tests cannot perform callouts to external web services

D. Unit tests can test single and bulk actions

A

B. Unit tests cannot send outbound email

C. Unit tests cannot perform callouts to external web services

D. Unit tests can test single and bulk actions