From b53057115722cacf1a7fcd6eee2786d1a0267516 Mon Sep 17 00:00:00 2001 From: Takao Chiba Date: Thu, 24 Aug 2023 07:47:37 +0800 Subject: [PATCH] Set JST time zone for robot tests --- .../confsched2023/testing/RobotTestRule.kt | 1 + .../confsched2023/testing/TimeZoneTestRule.kt | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/TimeZoneTestRule.kt diff --git a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/RobotTestRule.kt b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/RobotTestRule.kt index 94e7352b9..9ef4ca353 100644 --- a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/RobotTestRule.kt +++ b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/RobotTestRule.kt @@ -60,6 +60,7 @@ class RobotTestRule( return RuleChain .outerRule(HiltAndroidAutoInjectRule(testInstance)) .around(CoroutinesTestRule()) + .around(TimeZoneTestRule()) .around(object : TestWatcher() { override fun starting(description: Description) { // To see logs in the console diff --git a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/TimeZoneTestRule.kt b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/TimeZoneTestRule.kt new file mode 100644 index 000000000..8b9f13b2f --- /dev/null +++ b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/TimeZoneTestRule.kt @@ -0,0 +1,12 @@ +package io.github.droidkaigi.confsched2023.testing + +import org.junit.rules.TestWatcher +import org.junit.runner.Description +import java.util.TimeZone + +class TimeZoneTestRule : TestWatcher() { + override fun starting(description: Description) { + super.starting(description) + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Tokyo")) + } +}