Free DEV-450 Exam Braindumps (page: 6)

Page 6 of 96

How should a developer prevent a recursive trigger?

  1. Use a "one trigger per object" pattern.
  2. Use a static Boolean variable.
  3. Use a trigger handler.
  4. Use a private Boolean variable.

Answer(s): D



Which two statements are true about using the @testSetup annotation in an Apex test class? (Choose two.)

  1. The @testSetup annotation cannot be used when the @isTest(SeeAllData=True) annotation is used.
  2. Test data is inserted once for all test methods in a class.
  3. Records created in the @testSetup method cannot be updates in individual test methods.
  4. The @testSetup method is automatically executed before each test method in the test class is executed.

Answer(s): B,C

Explanation:

The @testSetup annotation is used to create a common set of records that can be used across all test methods in a test class. The primary benefit of using this annotation is to reduce the amount of redundant setup code needed in each individual test method. The @testSetup method is executed once per test class before any test methods are executed. The created data is available to all test methods in the class, but it cannot be updated by individual test methods.

Option A is incorrect because the @testSetup annotation can be used regardless of the @isTest(SeeAllData=True) annotation.

Option D is incorrect because the @testSetup method is only executed once per test class, not before each individual test method.



A developer wrote a unit test to confirm that a custom exception works properly in a custom controller, but the test failed due to an exception being thrown.
Which step should the developer take to resolve the issue and properly test the exception?

  1. Use try/catch within the unit test to catch the exception.
  2. Use the finally bloc within the unit test to populate the exception.
  3. Use the database methods with all or none set to FALSE.
  4. Use Test.isRunningTest() within the custom controller.

Answer(s): A



A developer writes the following code:


What is the result of the debug statement?

  1. 1, 100
  2. 1, 150
  3. 2, 150
  4. 2, 200

Answer(s): C






Post your Comments and Discuss Salesforce DEV-450 exam with other Community members:

DEV-450 Exam Discussions & Posts