Valid CRT-450 Dumps shared by ExamDiscuss.com for Helping Passing CRT-450 Exam! ExamDiscuss.com now offer the newest CRT-450 exam dumps, the ExamDiscuss.com CRT-450 exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com CRT-450 dumps with Test Engine here:
Which scenario is valid for execution by unit tests?
Correct Answer: C
Unit tests in Salesforce are designed to test Apex code functionality and can execute certain operations within the testing context. Option C: Generate a Visualforce PDF with getContentAsPDF Reference: "The getContent and getContentAsPDF PageReference methods can be used in test methods." - Apex Developer Guide: Testing GET and POST Methods Why Other Options Are Incorrect: Option A: Load data from a remote site with a callout Callouts to external services are not allowed in unit tests unless you use a mock callout framework. "Test methods can't make callouts to external systems. To test callouts, use mock callouts by either implementing an interface or using static resources." - Apex Developer Guide: Testing HTTP Callouts Option B: Execute anonymous Apex as a different user Executing anonymous Apex isn't possible within a test method, and you can't change the user context arbitrarily in tests except with System.runAs, which doesn't execute as a different user for anonymous code. "You can use System.runAs to run code as a different user, but you cannot execute anonymous Apex in this way within a test." - Apex Developer Guide: Running Apex as Another User Option D: Set the created date of a record using a system method System fields like CreatedDate are not writeable in Apex tests. "You can't set values for fields that have the Createable attribute set to false, such as system fields like CreatedDate or LastModifiedDate." - Apex Developer Guide: DML Statements
Recent Comments (The most recent comments are at the top.)
Recent Comments (The most recent comments are at the top.)
“Generate a Visual force PDF with getContentAsPDF()” is not a correct, getContentAsPDF() cannot be used in Test Methods.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_System_PageReference_getContentAsPDF.htm
The good answer is D. Link : https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_test.htm#apex_System_Test_setCreatedDate