I have a unit test which passes locally on the machine, but on bitrise it fails. Unit test has time in it.
@Test
fun `If time is later than now in hours, then show in hours`() = runTest {
clock.setInstant(Instant.ofEpochSecond(1686755085)) //Wed 14 Jun 16:05
val first = chargeTileInteractor12.observe().first()
assertEquals("in 3 hours", first.nextSessionDateText)
}
on bitrise unit test failed with error org.junit.ComparisonFailure: expected:<in [3] hours> but was:<in [4] hours>
function that it is calling
fun getNextSessionDateText(
clock: Clock,
targetDaySeconds: Int,
timeZoneId: ZoneId
): String {
val date = LocalDateTime.now(clock)
val nowDaySeconds = date.toLocalTime().toSecondOfDay()
return if (targetDaySeconds >= nowDaySeconds) {
val newSeconds = targetDaySeconds - nowDaySeconds
val newMinutes = secondsToMinutes(newSeconds.toLong())
val newHours = minutesToHoursRounded(newMinutes)
if (newHours > 0) {
"in $newHours hours"
} else if (newMinutes > 0) {
"in $newMinutes minutes"
} else {
"in $newSeconds seconds"
}
} else {
val newPastSeconds = nowToMidnightSeconds(timeZoneId) + targetDaySeconds
val newPastMinutes = secondsToMinutes(newPastSeconds)
val newPastHours = minutesToHoursRounded(newPastMinutes)
if (newPastHours > 0) {
"in $newPastHours hours"
} else if (newPastMinutes > 0) {
"in $newPastMinutes minutes"
} else {
"in $newPastSeconds seconds"
}
}
}
Any suggestions on how to get this to work please
Thanks R