nerdexam
Salesforce

PDI · Question #230

A developer is asked to write helper methods that create test data for unit tests. What should be changed in the Testvtils class so that its methods are only usable by unit test methods?

The correct answer is B. Add @IsTest above line 03,. The question asks how to make helper methods in a utility class callable exclusively by unit test methods.

Submitted by helene.fr· Apr 18, 2026Testing, Debugging, and Deployment

Question

A developer is asked to write helper methods that create test data for unit tests. What should be changed in the Testvtils class so that its methods are only usable by unit test methods?

Exhibit

PDI question #230 exhibit

Options

  • AChange public to private on line 01.
  • BAdd @IsTest above line 03,
  • CAdd @IsTest above line 01.
  • DRemove static from line 03.

How the community answered

(37 responses)
  • A
    3% (1)
  • B
    86% (32)
  • C
    3% (1)
  • D
    8% (3)

Why each option

The question asks how to make helper methods in a utility class callable exclusively by unit test methods.

AChange public to private on line 01.

Changing `public` to `private` for the class would prevent any other classes, including test classes, from accessing its methods.

BAdd @IsTest above line 03,Correct

Adding `@IsTest` above a method in a non-test class makes that specific method a test utility method, visible and callable only from other test methods or test classes, ensuring it's not used in production code.

CAdd @IsTest above line 01.

Adding `@IsTest` above the class definition would declare the entire class as a test class, which is not the specific goal of restricting individual helper methods within a potentially non-test utility class.

DRemove static from line 03.

Removing `static` would require instantiating the class to call the method but would not restrict its callable context to only unit test methods.

Concept tested: @IsTest annotation for test utility methods

Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_isTest.htm

Topics

#Apex Testing#@IsTest#Test Utility Classes#Test Methods

Community Discussion

No community discussion yet for this question.

Full PDI Practice