Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test always fails in local env #2979

Closed
EmmanuelMess opened this issue Nov 4, 2021 · 8 comments · Fixed by #3119
Closed

Test always fails in local env #2979

EmmanuelMess opened this issue Nov 4, 2021 · 8 comments · Fixed by #3119
Assignees
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Area-Test Related to tests (Robolectric, Espresso, JUnit)
Milestone

Comments

@EmmanuelMess
Copy link
Member

Running :app:testPlayDebugUnitTest always fails with:

com.amaze.filemanager.asynchronous.asynctasks.compress.EncryptedRarHelperTaskTest > testRoot[16] FAILED
    java.lang.Exception at AndroidTestEnvironment.java:470
        Caused by: java.lang.AssertionError at Assert.java:89
@EmmanuelMess EmmanuelMess added Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Area-Test Related to tests (Robolectric, Espresso, JUnit) labels Nov 4, 2021
@TranceLove
Copy link
Collaborator

@EmmanuelMess Can you run the test standalone from within Android Studio?

Also, try get a jacoco test report. It should contain more info on what had gone wrong for me to fix this.

@EmmanuelMess
Copy link
Member Author

EmmanuelMess commented Nov 4, 2021

I cannot run the test from Android Studio either. It might be a timezone issue.

java.lang.Exception: Main looper has queued unexecuted runnables. This might be the cause of the test failure. You might need a shadowOf(getMainLooper()).idle() call.
	at org.robolectric.android.internal.AndroidTestEnvironment.checkStateAfterTestFailure(AndroidTestEnvironment.java:470)
	at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:548)
	at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:252)
	at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.AssertionError: expected:<1527590280000> but was:<1527601080000>
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.failNotEquals(Assert.java:835)
	at org.junit.Assert.assertEquals(Assert.java:647)
	at org.junit.Assert.assertEquals(Assert.java:633)
	at com.amaze.filemanager.asynchronous.asynctasks.compress.AbstractCompressedHelperTaskTest.testRoot(AbstractCompressedHelperTaskTest.kt:83)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	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:546)
	... 6 more

@TranceLove
Copy link
Collaborator

@EmmanuelMess Sounds like timezone problem on timestamp assertion differences. Same thing happened on zip tests earlier, so I think should be about the same problem.

Will advise after further inspection.

@TranceLove
Copy link
Collaborator

TranceLove commented Nov 6, 2021

Made an initial test with separate VM running Debian 11, and timezone deliberately set to GMT-3, i.e. the same timezone as in Buenos Aires😎 gradle build from the command line ran ok.

Will check with tests ran from within IDE. May involve setting TZ environment variable at test run configuration.

@TranceLove
Copy link
Collaborator

Ran from within Debian VM of timezone = Buenos Aires again, running EncryptedRarHelperTaskTest will fail without setting TZ to UTC in run configurations.

So perhaps this is how to solve your problem - set environment variable TZ to UTC in your run configuration in Android Studio. Github action YAML and gradlew/gradlew.bat had already had this set, so they won't be affected.

@EmmanuelMess
Copy link
Member Author

I dont understand why that fact that I run it under another timezone changes the result of the test, isn't everything converted to UTC timezone?

@TranceLove
Copy link
Collaborator

@EmmanuelMess Zip and rar formats are still using DOS timestamps, which is timezone sensitive. Things got a little tricky when verifying their timestamps, hence setting timezone to UTC to hopefully reduce the impact of the problem.

@EmmanuelMess
Copy link
Member Author

Zip and rar formats are still using DOS timestamps, which is timezone sensitive.

Can't the timezone be set in code for this test?

@TranceLove TranceLove self-assigned this Jan 10, 2022
TranceLove added a commit to TranceLove/AmazeFileManager that referenced this issue Jan 10, 2022
TranceLove added a commit to TranceLove/AmazeFileManager that referenced this issue Jan 11, 2022
@VishalNehra VishalNehra added this to the v3.7 milestone Jan 12, 2022
@VishalNehra VishalNehra changed the title Test always fails on my PC Test always fails in local env Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Area-Test Related to tests (Robolectric, Espresso, JUnit)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants