How can I mock java.time.LocalDate.now()

后端 未结 7 1258
迷失自我
迷失自我 2020-12-01 01:02

In my test case, I need test time sensitive method, in that method we\'re using java 8 class LocalDate, it is not Joda.

What can I do to change time

相关标签:
7条回答
  • 2020-12-01 02:01

    You might also want to pass a fixed clock in production (the value of which is fixed at the start of a transaction) to avoid using inconsistent "now" in different entities and requests. See this question for details.

    0 讨论(0)
提交回复
热议问题