<< Prev Question Next Question >>

Question 12/68

Which scenario is valid for execution by unit tests?

Recent Comments (The most recent comments are at the top.)

Ron Snider - Sep 16, 2024

The correct answer is C. Set the created date of a record using a system method.

Here's a breakdown of each scenario:

A. Generate a Visualforce PDF with getContentAsPDF(): This is invalid in unit tests. Methods like getContent() or getContentAsPDF() that require making real HTTP requests or interacting with the UI are not allowed in tests because unit tests should run without reliance on external factors like the rendering of Visualforce pages.

B. Load data from a remote site with a callout: This is also invalid in unit tests. Salesforce requires the use of mock callouts in test methods to simulate callouts, rather than performing real HTTP callouts.

C. Set the created date of a record using a system method: This is valid in unit tests. You can use Test.setCreatedDate(recordId, datetime) to manipulate the created date for testing purposes in Salesforce unit tests.

D. Execute anonymous Apex as a different user: This is invalid for unit tests. Unit tests run in the context of a test execution and do not allow for executing anonymous code or switching users arbitrarily....

LEAVE A REPLY

Your email address will not be published. Required fields are marked *

Question List (68q)
2 commentQuestion 1: A developer needs to have records with specific field values...
3 commentQuestion 2: What should a developer do to check the code coverage of a c...
1 commentQuestion 3: A developer must create a CreditcardPayment class that provi...
1 commentQuestion 4: A developer created a trigger on the Account object and want...
1 commentQuestion 5: Universal Containers has a Visualforce page that displays a ...
1 commentQuestion 6: When a user edits the Postal Code on an Account, a custom Ac...
4 commentQuestion 7: A developer wants to invoke on outbound message when a recor...
2 commentQuestion 8: The values 'High', 'Medium', and 'Low' are Identified as com...
Question 9: A developer Is Integrating with a legacy on-premise SQL data...
Question 10: Universal Container* decides to use purely declarative devel...
1 commentQuestion 11: A developer is creating a Lightning web component to showa l...
2 commentQuestion 12: Which scenario is valid for execution by unit tests?...
3 commentQuestion 13: What are two use cases for executing Anonymous Apex code? Ch...
5 commentQuestion 14: What are three characteristics of change set deployments? Ch...
1 commentQuestion 15: Universal Containers hires a developer to build a custom sea...
2 commentQuestion 16: Universal Containers stores the availability date on each Li...
1 commentQuestion 17: Which statement describes the execution order when trigger a...
4 commentQuestion 18: A developer must implement a CheckPaymentProcessor class tha...
2 commentQuestion 19: For which three items can 2 trace flag be configured? Choose...
1 commentQuestion 20: What are three ways for a developer to execute tests in an o...
4 commentQuestion 21: The Job_Application__c custom object has a field that is a M...
6 commentQuestion 22: Refer to the following code snippet for an environment has m...
Question 23: A developer has the following requirements: * Calculate the ...
1 commentQuestion 24: A developer is writing tests for a class and needs to insert...
Question 25: n org has an existing flow that creates an Opportunity with ...
5 commentQuestion 26: The following code snippet is executed by a Lightning web co...
2 commentQuestion 27: Universal Container is building a recruiting app with an App...
4 commentQuestion 28: In the Lightning UI, where should a developer look to find i...
Question 29: What are two ways for a developer to execute tests in an org...
2 commentQuestion 30: A developer observes that an Apex test method fails in the S...
Question 31: The Account object in an organization has a master detail re...
Question 32: A development team wants to use a deployment script lo autom...
2 commentQuestion 33: A developer wrote an Apex method to update a list of Contact...
2 commentQuestion 34: Which Lightning code segment should be written to declare de...
Question 35: Cloud kicks has a multi-screen flow that its call center age...
Question 36: A developer is migrating a Visualforce page into a Lightning...
Question 37: Which Apex class contains methods to return the amount of re...
3 commentQuestion 38: What should a developer use to script the deployment and uni...
Question 39: A developer must provide custom user interfaces when users e...
4 commentQuestion 40: Which two are best practices when it comes to component and ...
3 commentQuestion 41: What is the result of the following code?...
Question 42: Refer to the following Apex code: (Exhibit) What is the valu...
Question 43: Cloud kicks has a muli-screen flow its call center agents us...
3 commentQuestion 44: An Apex method, getAccounts, that returns a list of Accounts...
2 commentQuestion 45: A developer created a custom order management app that uses ...
Question 46: A developer is debugging the following code to determinate w...
2 commentQuestion 47: Given the following code snippet, that is part of a custom c...
5 commentQuestion 48: What are two ways a developer can get the status of an enque...
1 commentQuestion 49: A developer is tasked to perform a security review of the Co...
1 commentQuestion 50: Which two sfdx commands can be used to add testing data to a...
1 commentQuestion 51: A developer wants to get access to the standard price book i...
1 commentQuestion 52: What are three ways for 2 developer to execute tests in an o...
Question 53: When a user edits the postal Code on an Account, a custom Ac...
Question 54: A custom picklist field, Food_Preference__c, exist on a cust...
Question 55: When a user edits the Postal Code on an Account, a custom Ac...
4 commentQuestion 56: A business has a proprietary Order Management System (OMS) t...
3 commentQuestion 57: Refer to the following code snippet for an environment that ...
3 commentQuestion 58: A custom object Trainer_c has a lookup field to another cust...
Question 59: What can be used to override the Account's standard Edit but...
6 commentQuestion 60: A developer considers the following snippet of code: (Exhibi...
Question 61: A developer is creating an app that contains multiple Lightn...
1 commentQuestion 62: How can a developer check the test coverage of active Proces...
4 commentQuestion 63: When importing and exporting data into Salesforce, which two...
1 commentQuestion 64: A developer must create a lightning component that allows us...
1 commentQuestion 65: A software company uses the following objects and relationsh...
Question 66: Which action causes a before trigger to fire by default for ...
1 commentQuestion 67: A Salesforce Administrator is creating a record-triggered fl...
Question 68: Universal Containers implemented a private sharing model for...