Courseiva

CCNA Testing Debugging And Deployment Questions

32 of 107 questions · Page 2/2 · Testing Debugging And Deployment · Answers revealed

76
Multi-Selectmedium

Which THREE pieces of information are displayed in the Apex Test Execution page?

Select 3 answers
A.Code Coverage Percentage.
B.Execution Status.
C.Test Class Name.
D.Execution Time.
E.User who initiated the test.
AnswersB, C, D

Shows pass/fail.

Why this answer

The page shows class name, status, and duration.

77
Multi-Selecthard

Which THREE items are best practices when setting up test data using @TestSetup methods? (Choose three.)

Select 3 answers
A.Perform time-consuming operations or bulk data generation once to avoid hitting governor limits in separate test methods.
B.Hardcode specific record IDs assigned during @TestSetup into downstream test assertions.
C.Create parent records (such as Accounts) that can be queried and associated with child records in individual test methods.
D.Call external REST callouts inside the @TestSetup method to fetch live seed data.
E.Modify records created in @TestSetup within test methods without worrying about state pollution, because Salesforce automatically rolls back modifications made by each test method.
AnswersA, C, E

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

78
MCQeasy

Which log level displays the most information?

A.WARN.
B.DEBUG.
C.INFO.
D.FINEST.
AnswerD

Most detailed level.

Why this answer

FINEST is the most granular log level available.

79
Multi-Selecthard

Which THREE things can a developer do with the Salesforce CLI?

Select 3 answers
A.Modify the Org's license type.
B.Query data from an org.
C.Update user passwords.
D.Create a scratch org.
E.Deploy metadata to an org.
AnswersB, D, E

Core CLI feature.

Why this answer

The CLI supports org management, code deployment, and data management.

80
MCQeasy

Which tool is best suited for running all tests in an org and viewing the code coverage percentages?

A.Salesforce Setup Menu
B.Developer Console
C.Change Sets
D.Workbench
AnswerB

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.

81
MCQeasy

Which of these is NOT a valid testing best practice?

A.Testing for bulk records.
B.Using System.assertEquals.
C.Using @isTest.
D.Hard-coding record IDs.
AnswerD

This is a bad practice.

Why this answer

Hard-coding data is a bad practice.

82
MCQhard

When testing asynchronous Apex, how do you ensure that the scheduled job has finished before asserting results?

A.Use Test.stopTest()
B.Query the AsyncApexJob object
C.Use System.runAs()
D.Use Thread.sleep()
AnswerA

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.

83
MCQmedium

What is the primary benefit of using a Sandbox for development?

A.It allows access to the full production database automatically.
B.It increases the number of available governor limits.
C.It allows development without affecting production data.
D.It automatically deploys code to production.
AnswerC

Provides a safe environment for testing.

Why this answer

Sandboxes provide an isolated environment to prevent impact on production data or processes.

84
MCQhard

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?

A.Wrap the test assertion code between Test.startTest() and Test.stopTest().
B.Mark the test method with @isTest(SeeAllData=true).
C.Wrap the trigger logic in a Database.setSavepoint() block.
D.Use Limits.getLimitQueries() inside the test method.
AnswerA

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().

85
MCQeasy

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?

A.100%
B.50%
C.75%
D.85%
AnswerC

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.

86
MCQmedium

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?

A.sf org login web
B.sf org create sandbox
C.sf project retrieve start
D.sf org create scratch
AnswerD

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.

87
MCQmedium

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?

A.The Developer Console caches old test results automatically.
B.The test class lacks the @isTest annotation.
C.Governor limits are permanently exhausted for the entire session.
D.Test data pollution caused by another test method modifying shared records without resetting state.
AnswerD

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.

88
MCQhard

A developer is using 'Test.isRunningTest()' in their production code. Why is this generally considered a poor practice?

A.It creates different code execution paths between test and production
B.It causes the test to fail
C.It causes excessive governor limit usage
D.It is not supported in production
AnswerA

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.

89
MCQhard

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?

A.Use System.runAs() to execute the test under a user with API Enabled permissions
B.Use Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator())
C.Wrap the trigger logic inside a Test.startTest() and Test.stopTest() block without mocks
D.Set the remote site setting dynamically inside the test method before the trigger fires
AnswerB

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().

90
MCQmedium

Which of the following describes the behavior of Test.stopTest()?

A.It clears all variables created in the test.
B.It forces all queued asynchronous jobs to complete.
C.It resets the debug logs.
D.It stops all further execution of the test class.
AnswerB

Main function of stopTest.

Why this answer

It executes all asynchronous code queued during the test.

91
Multi-Selectmedium

Which TWO features of @isTest(SeeAllData=true) should a developer be aware of?

Select 2 answers
A.It speeds up test execution.
B.It is required for testing standard objects.
C.It ignores all governor limits.
D.It makes tests results dependent on the org's existing data.
E.It exposes all existing data in the org to the test method.
AnswersD, E

True, this is the main risk.

Why this answer

It grants access to all org data and can lead to unexpected test results.

92
MCQeasy

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?

A.Tests tab
B.Query Editor tab
C.DOM Inspector tab
D.Logs tab
AnswerA

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.

93
MCQeasy

Which utility class is used to assert that code behaves as expected in Apex tests?

A.Test.assert().
B.Test.verify().
C.Assert.verify().
D.System.assertEquals().
AnswerD

Correct method for assertions.

Why this answer

The System.assertEquals method is the standard way to verify expected outcomes.

94
MCQmedium

How can a developer inspect the state of a private variable within a class during unit testing?

A.Change the class to @isTest.
B.Use the @TestVisible annotation.
C.There is no way to inspect private variables.
D.Make the variable public.
AnswerB

Safely exposes private members to tests.

Why this answer

@TestVisible allows test classes to access private variables without making them public.

95
Multi-Selectmedium

Which TWO of the following are valid ways to trigger an Apex test run?

Select 2 answers
A.From the User record.
B.By editing an Apex class.
C.Apex Test Execution page in Setup.
D.From a Workflow Rule.
E.Developer Console.
AnswersC, E

Standard UI for running tests.

Why this answer

Tests can be run from the Developer Console and from the Apex Test Execution page.

96
MCQhard

What is the primary constraint on using @testSetup?

A.It creates data that is isolated from the test methods.
B.It must be a void method.
C.It cannot interact with the database.
D.It can only be used once per project.
AnswerB

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.

97
MCQmedium

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?

A.ERROR
B.FINEST
C.INFO
D.DEBUG
AnswerB

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.

98
MCQhard

What happens if a test class has a method annotated with @testSetup that fails to insert data?

A.The test execution proceeds, but without data.
B.The platform ignores the @testSetup failure.
C.The entire test class fails to execute.
D.Only the first test method fails.
AnswerC

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.

99
MCQmedium

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?

A.Unmanaged change sets require manual XML editing prior to upload.
B.Change sets do not support the deployment of custom fields under any circumstances.
C.Field-level security settings on profiles are sometimes omitted or overridden if the target profile already exists and has conflicting security configurations.
D.Profiles cannot be included in outbound change sets.
AnswerC

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.

100
MCQhard

When testing a trigger, why should you avoid hard-coding IDs?

A.It violates Apex syntax rules.
B.It limits the test to only one record.
C.It triggers governor limits.
D.IDs change between orgs, causing test failures.
AnswerD

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.

101
MCQeasy

Which annotation is required for a method to be recognized by the Apex test runner?

A.@testMethod.
B.@TestVisible.
C.@future.
D.@isTest.
AnswerD

@isTest defines the class or method as a test.

Why this answer

@isTest is the required annotation for test classes and methods.

102
MCQmedium

What is the primary purpose of the 'System.debug()' statement?

A.To display an error to the end user
B.To stop the execution of the code
C.To log an audit trail of configuration changes
D.To write information to the debug log
AnswerD

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.

103
Multi-Selectmedium

Which THREE of the following are true about Apex test data setup?

Select 3 answers
A.@TestSetup methods run once per test class
B.Test data is automatically committed to the database
C.Tests can use existing data from the org if 'SeeAllData=true' is set
D.Test data must be inserted into the database to be queryable
E.Test classes can only use data created within the same method
AnswersA, C, D

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.

104
MCQmedium

How can you run tests for a specific namespace using the CLI?

A.Using the --package flag.
B.Using the --namespace flag.
C.You cannot filter by namespace.
D.By running all tests.
AnswerB

Correct flag.

Why this answer

The CLI supports filtering tests by namespace.

105
MCQhard

When using the Salesforce CLI to deploy, what is the 'check-only' flag used for?

A.To validate the metadata without saving it to the org.
B.To force the deployment despite test failures.
C.To skip the compilation check.
D.To run only the tests.
AnswerA

Provides a dry run.

Why this answer

It validates the deployment without committing changes to the target org.

106
Multi-Selecthard

Which THREE factors influence deployment success?

Select 3 answers
A.The number of users.
B.Profile/Permission Set permissions.
C.Dependent components.
D.Test coverage.
E.The color of the UI.
AnswersB, C, D

Required for access.

Why this answer

Tests, dependencies, and profile permissions are critical.

107
Multi-Selectmedium

Which TWO of the following are valid deployment tools?

Select 2 answers
A.Salesforce CLI.
B.Change Sets.
C.System Log.
D.Developer Console Debugger.
E.Apex Test Runner.
AnswersA, B

Valid tool.

Why this answer

Change Sets and Salesforce CLI are standard tools.

← PreviousPage 2 of 2 · 107 questions total

Ready to test yourself?

Try a timed practice session using only Testing Debugging And Deployment questions.