Which THREE pieces of information are displayed in the Apex Test Execution page?
Shows pass/fail.
Why this answer
The page shows class name, status, and duration.
32 of 107 questions · Page 2/2 · Testing Debugging And Deployment · Answers revealed
Which THREE pieces of information are displayed in the Apex Test Execution page?
Shows pass/fail.
Why this answer
The page shows class name, status, and duration.
Which THREE items are best practices when setting up test data using @TestSetup methods? (Choose three.)
@TestSetup runs once per class, preserving governor limits for test methods.
Why this answer
Test setup methods create shared records efficiently and roll back per method.
Which log level displays the most information?
Most detailed level.
Why this answer
FINEST is the most granular log level available.
Which THREE things can a developer do with the Salesforce CLI?
Core CLI feature.
Why this answer
The CLI supports org management, code deployment, and data management.
Which tool is best suited for running all tests in an org and viewing the code coverage percentages?
The Developer Console is the primary tool for testing and coverage analysis.
Why this answer
The Developer Console provides a built-in interface to run tests and view code coverage immediately.
Which of these is NOT a valid testing best practice?
This is a bad practice.
Why this answer
Hard-coding data is a bad practice.
When testing asynchronous Apex, how do you ensure that the scheduled job has finished before asserting results?
Test.stopTest() executes all asynchronous operations queued during the test.
Why this answer
Test.stopTest() forces any asynchronous processes, such as @future or Schedulables, to execute before the code execution continues.
What is the primary benefit of using a Sandbox for development?
Provides a safe environment for testing.
Why this answer
Sandboxes provide an isolated environment to prevent impact on production data or processes.
A developer receives a System.LimitException: Too many SOQL queries: 101 when running a complex unit test. The test class inserts a large volume of test records that inadvertently cause a trigger to execute multiple queries inside a loop. What is the most effective way to reset the governor limits specifically for the code being tested?
Test.startTest and Test.stopTest reset governor limits so that heavy test setup data generation does not count against the tested code limits.
Why this answer
Test.startTest() resets all governor limits for the code executed immediately following it, up until Test.stopTest().
A developer needs to verify code coverage across an entire Apex organization before deploying code to production. What is the minimum overall Apex code coverage required by Salesforce for production deployment?
Salesforce requires at least 75% of all Apex code in the org to be covered by unit tests.
Why this answer
Salesforce requires a minimum of 75% overall Apex code coverage for deployment to a production organization.
A developer is using Salesforce CLI to create a temporary environment for feature development and testing that includes all source code and shape settings. Which CLI command should the developer use to create this temporary environment?
sf org create scratch creates a source-tracked scratch org using a project-scratch-def.json file.
Why this answer
sf org create scratch creates a scratch org based on a definition file.
A developer runs unit tests in the Developer Console and notices that one test method fails when run as part of the entire test class, but passes successfully when run in isolation. What is the most likely cause of this issue?
Shared state and lack of data isolation between methods in the same class can cause dependent test failures.
Why this answer
Test pollution occurs when test data modified or created by one test method is not properly cleaned up, affecting subsequent test methods.
A developer is using 'Test.isRunningTest()' in their production code. Why is this generally considered a poor practice?
It is better to avoid conditional logic that changes runtime behavior based on test context.
Why this answer
While sometimes necessary, relying on it can lead to code paths that are not tested in production exactly as they execute in tests.
An Apex trigger performs a callout to an external web service and a developer is writing a unit test for this trigger. How should the developer handle the callout during the test execution?
Test.setMock informs the runtime to return a simulated response instead of making a real callout.
Why this answer
Apex runtime throws an exception if a callout is attempted in a test without being mocked. The developer must implement the HttpCalloutMock interface and use Test.setMock().
Which of the following describes the behavior of Test.stopTest()?
Main function of stopTest.
Why this answer
It executes all asynchronous code queued during the test.
Which TWO features of @isTest(SeeAllData=true) should a developer be aware of?
True, this is the main risk.
Why this answer
It grants access to all org data and can lead to unexpected test results.
A developer wants to inspect the code coverage of individual classes directly within the Salesforce Developer Console. Under which tab can the developer view this breakdown?
The Tests tab displays test suites, test runs, and code coverage metrics.
Why this answer
The Tests tab in the Developer Console displays test execution status, test results, and code coverage percentages by class.
Which utility class is used to assert that code behaves as expected in Apex tests?
Correct method for assertions.
Why this answer
The System.assertEquals method is the standard way to verify expected outcomes.
How can a developer inspect the state of a private variable within a class during unit testing?
Safely exposes private members to tests.
Why this answer
@TestVisible allows test classes to access private variables without making them public.
Which TWO of the following are valid ways to trigger an Apex test run?
Standard UI for running tests.
Why this answer
Tests can be run from the Developer Console and from the Apex Test Execution page.
What is the primary constraint on using @testSetup?
Correct, @testSetup must return void.
Why this answer
It cannot be used with @isTest(SeeAllData=true) in a way that allows access to existing data for setup.
You are debugging a performance issue in an Apex trigger. You want to see the database resource usage. Which debug log level should you set for the Database category?
FINEST captures the most detailed information including database performance.
Why this answer
The FINEST level for the Database category captures the most detailed information, including resource usage and DML/SOQL performance metrics.
What happens if a test class has a method annotated with @testSetup that fails to insert data?
Setup is a prerequisite for the class.
Why this answer
The test class setup fails, and all test methods in the class will fail to execute.
A developer is deploying a profile and custom fields using an Unmanaged Change Set. Upon deployment, some custom field permissions fail to apply correctly in production. What is the most likely cause of this behavior?
Existing profiles in target orgs can cause permission merge conflicts during change set deployments.
Why this answer
Profiles and permission sets in change sets require careful component selection, and field-level security is often best handled via permission sets or post-deployment steps.
When testing a trigger, why should you avoid hard-coding IDs?
Code should query for data or create it dynamically.
Why this answer
IDs are not consistent across environments, which causes tests to fail in deployment.
Which annotation is required for a method to be recognized by the Apex test runner?
@isTest defines the class or method as a test.
Why this answer
@isTest is the required annotation for test classes and methods.
What is the primary purpose of the 'System.debug()' statement?
This is the intended function of System.debug.
Why this answer
System.debug() writes information to the debug log to help developers diagnose execution flow and variable states.
Which THREE of the following are true about Apex test data setup?
This is the correct behavior for @TestSetup.
Why this answer
Data setup should use @TestSetup where possible, avoid using actual production data, and be isolated from the database.
How can you run tests for a specific namespace using the CLI?
Correct flag.
Why this answer
The CLI supports filtering tests by namespace.
When using the Salesforce CLI to deploy, what is the 'check-only' flag used for?
Provides a dry run.
Why this answer
It validates the deployment without committing changes to the target org.
Which THREE factors influence deployment success?
Required for access.
Why this answer
Tests, dependencies, and profile permissions are critical.
Which TWO of the following are valid deployment tools?
Valid tool.
Why this answer
Change Sets and Salesforce CLI are standard tools.
Ready to test yourself?
Try a timed practice session using only Testing Debugging And Deployment questions.