Today, we had a team debate about our Integration Tests (spring application) - during which - two different Clock approaches emerged.
1) We Should always use fixed Clock implementation during our unit/integration tests
- It drives your code to always include Clock in constructor (DI), so to be testable
- It makes easy to control time flow (in tests that need it)
- Makes tests more "descriptive" because, you literally show class relation to time flow
2) Use fixed Clock implementation ONLY when your TestClass explicitly needs it to control time flow.
- Integration tests should use closest to production implementation possible
So #1 approach buffs test classes, but #2 seems to be "more true" in some situations.
And the question: How do you handle Clock/Time in your Projects? Please share your experience and arguments!
Aucun commentaire:
Enregistrer un commentaire