CatimaLoyalty / Android

Catima, a Loyalty Card & Ticket Manager for Android
https://catima.app
GNU General Public License v3.0
886 stars 151 forks source link

startWithLoyaltyCardNoExpirySetExpiry test can fail depending on time(zone) #2124

Open obfusk opened 1 month ago

obfusk commented 1 month ago

I had an odd test failure. Running the tests with TZ=UTC fixed it (it was indeed the 22nd in my time zone but still the 21st in UTC).

org.junit.ComparisonFailure: expected:<October 2[2], 2024> but was:<October 2[1], 2024>
    at org.junit.Assert.assertEquals(Assert.java:117)
    at org.junit.Assert.assertEquals(Assert.java:146)
    at protect.card_locker.LoyaltyCardViewActivityTest.checkFieldProperties(LoyaltyCardViewActivityTest.java:293)
    at protect.card_locker.LoyaltyCardViewActivityTest.checkAllFields(LoyaltyCardViewActivityTest.java:320)
    at protect.card_locker.LoyaltyCardViewActivityTest.startWithLoyaltyCardNoExpirySetExpiry(LoyaltyCardViewActivityTest.java:741)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:489)
    at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:291)
    at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:104)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
TheLastProject commented 1 month ago

Every now and then I get an email from someone who says setting an expiry "doesn't work". Most people don't respond when I ask them what "doesn't work" means, one person stated it "sets the wrong day". Sadly even that person didn't further respond when I asked them which day they entered and what they go and what timezone they're in. I've long suspected there was some timezone related issue there but I never had enough info to justify spending a lot of time taking a look so this test failure may actually be showing that issue. Maybe it'll help actually fix whatever is going wrong.