문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top