jeudi 3 mars 2016

How to mock current date?

I have a method in my code which verifies that current day is business. it checks database calendar for this.

method looks like this:

public boolean iBusinessDayToday() {
      LocalDate today = LocalDate.now();
      //logic with today
}

I need to write unit tests for this.

I want that unit test doesn't depends in week day.

What do you think need this issue to use powerMockito to mock LocalDate.now() ?

Aucun commentaire:

Enregistrer un commentaire