[Office Hours] is there a way to mock dates in unit tests? #97
Replies: 2 comments 1 reply
-
I'm guessing you have static dates for your prescription test data and trying to compare that with today? Option2: Best practice |
Beta Was this translation helpful? Give feedback.
-
Hi @kkellybonilla, Along the lines of what @ChenaLee has mentioned in her comment, there is a "simple" dependency injection mechanism you can use here to inject a function that generates the date, as described here. @PSchmiedmayer do you have any advice here? |
Beta Was this translation helpful? Give feedback.
-
Related Discussion
Is there a way to properly mock dates in unit tests? I attempted to mock them as such:
but i think it may be causing race conditions since sometimes my tests pass and at other times they don't. i remember briefly reading that swift unit tests run concurrently, though i'm not certain.
Reproduction
N/A
Additional context
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions