I want to write some test cases for my web app, but stuck at some cases such as “This token should be expired in 30 days”. Nobody likes to wait for 30 days before the tests finish.
There are also other cases regarding some scheduled events to happen, like “Send this email 2 weeks after the user sign up”, “Generate a bill 2 days before next billing date”, etc.
What suggestion do you have on writing such test cases? Or, is there another way of making sure that these functions work as precisely as designed?
My approach when writing these tests is to define the expiration in milliseconds. That way you can easily write tests because your test environments can define an expiration of 1 ms. The production environment will obviously define the appropriate duration. Typically these can be set as config values or db values.