I'm having some troubles shadowing TimeZone.getDefault()
using Robolectric since my AppTest.class is not using my static shadow mwthod in ShadowTimeZone.class.
AppTest.class
@RunWith(RobolectricTestRunner.class)
@Config(manifest = "../App/AndroidManifest.xml")
public class AppTest{
@Test
@Config(shadows = {ShadowTimeZone.class})
public void testTimeZone() {
String expectedTimeZoneId = "Europe/London";
TimeZone timeZone = TimeZone.getDefault();
assertThat(timeZone.getID(), equalTo(expectedTimeZoneId));
}
}
ShadowTimeZone.class
@Implements(TimeZone.class)
public class ShadowTimeZone {
@Implementation
public static TimeZone getDefault() {
return TimeZone.getTimeZone("Europe/London");
}
}