Time dependent unit tests

前端 未结 5 1391
萌比男神i
萌比男神i 2020-11-27 14:09

I need to test a function that whose result will depend on current time (using Joda time\'s isBeforeNow(), it so happens).

public boolean isAvai         


        
5条回答
  •  失恋的感觉
    2020-11-27 14:11

    Java 8 introduced the abstract class java.time.Clock which allows you to have an alternative implementation for testing. This is exactly what Jon suggested in his answer back then.

提交回复
热议问题