The "unit test" A value becomes B in 300 seconds. How can I test this interface?

Thank you @ betacat for reminding me. I"ll delete the previous rough example and give a specific scenario:

suppose I need to test a strategy game. At present, the resources are 15 units, and the resources will not be updated until at least 300 seconds. According to the formula, the resources should be 35 units after 300 seconds.

if the time value of the interface is obtained from the system time, it is difficult for me to forge it directly. So I would like to ask: how can I quickly test .

I don"t know what the bosses have in mind.

< hr >

optional crab: more comprehensive test books or medium-and long-length tutorials (unlimited language, confused about "Why to write tests" and "how to design good and comprehensive tests"), please recommend

< hr >

@ original sin teacher provides Observer Mode: test code subscribe to event topics, and real executors publish event topics. This coupling is the lowest "answer", although it does not solve my confusion of "how to test quickly", but it is very instructive.

because it is in the comments, it is posted for your reference. Thanks again to the two bosses who answered: d .

Mar.22,2021

you mean the front end, right? Frameworks like mocha or jasmine pass in an end function of done when test.

  

laxatives. I suggest using msg or ioc to separate the operation of obtaining time, and then directly hook msg the reply,ioc that forges the time, and then directly mock a fake object to return the forged time.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c3150a-335ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c3150a-335ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?