Here is my test :
@Test
fun determineIsNotInFuture() {
val fakeTimeRecord = TimeRecord()
val dateTimeNow = LocalDate.of( 2020 , Month.JANUARY , 1 )
val dateTimeLater = LocalDate.of(2020, Month.JANUARY, 10)
var fakeCalendar = Calendar.getInstance()
fakeCalendar.time = Date.from(dateTimeNow.atStartOfDay(ZoneId.systemDefault()).toInstant())
fakeTimeRecord.punch = Punch()
fakeTimeRecord.punch!!.punchIn = Date.from(dateTimeLater.atStartOfDay(ZoneId.systemDefault()).toInstant())
val isInFuture = timeRecordHelper.determineIfPunchInIsIntheFuture(fakeTimeRecord.getPunchIn(), fakeCalendar)
assertEquals(true, isInFuture)
}
What I am really trying to test is this time record helper functions returning true correctly when given a know date for the current time and know date for the time punch.
The test runs and tests my function accuratly but I have a new instance of calendar, is there any advantage to mocking the calander instance ?
Aucun commentaire:
Enregistrer un commentaire