unit testing - System.Today() and System.Now() in test class -
how can mockup system.today() , system.now() in test class further logic?
i remember sf having limitation while not sure if came new.
depending on code doing, possible modify code pull logic involved separate method pass in system.today() or system.now(). @ point can test component , pass in date/datetime of choosing.
for example, if code following testability:
system.debug(system.now().adddays(2)); changes to:
public static datetime adddays(datetime d, integer i) { return d.adddays(i); } system.debug(adddays(system.now(), 2));
Comments
Post a Comment