function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Why test class has static methods, Void return type and No parameters ?

Leonardi KohLeonardi Koh
Test class CAN contain methods that have return value and parameters... (typically to be called by the testMethod in that class or another test class)

But the test class methods that is marked with testMethods or @isTest (and thus will be run by the system when the test class is being used) would not have them since those methods are what's going to be run by the system when the test class is called or needed (like when deploying) and the user would not be supplying parameters when this occurs ... and nor should they.

As the developer, it is our job to ensure these test class methods we build that are marked with testMethods or @isTest  perform the simulated scenario / testing based on the condition that needed to be tested (hence why no parameters on them, the parameter of the scenario is built into the method with the testMethods). And the goal of the test class is ultimately to simulate the scenario where the class we wanted to test are being utilized, and validate the outcome (hence why no return type for these methods, because that's not the purpose of them).