Pregunta

My service has long running processes. For example - user can signup, but if email not verified after 7 days, we send a reminder email.

I need my system test to cover this scenario as well.

Currently, I manipulate the data in the DB so the system thinks the user signed up a week ago.

But this makes my tests tightly coupled with the model and the code itself and the developers.

Is there a better way to handle this?

¿Fue útil?

Solución

First, a time value like "7 days" should be a configuration parameter of your process, not something hardcoded or something the process can exclusively retrieve from the database. When you implement the system like that, your system test can replace "7 days" by something like "7 seconds", which should solve your problem.

The other approach I see is to make the clock an abstraction which can be passed as an interface into the process, so you can mock out the "real" clock by a mocked version for testing purposes.

Otros consejos

Time skipping might affect other system tests

That rules out a lot of tools, but timecop might help you by accelerating time without skipping (disclaimer- I have never used it myself)

Licenciado bajo: CC-BY-SA con atribución
scroll top