oppia / oppia-android

A free, online & offline learning platform to make quality education accessible for all.
https://www.oppia.org
Apache License 2.0
301 stars 502 forks source link

[BUG]: ActivityScenarioRule causes issues with platform parameter initialization #5307

Open BenHenning opened 5 months ago

BenHenning commented 5 months ago

Describe the bug

During the development of #5138 it was discovered that ActivityScenarioRule can cause issues with any module-override static initialization (such as platform parameters). This is most likely to happen with platform parameters, and it manifests as the parameters not properly setting for some of the tests (due to the scenario being set up before the module override can occur in the test).

Steps To Reproduce

Trying to run specific tests in ProfileAndDeviceIdFragmentTest can fail due to the platform parameters needed for the test not being properly set up ahead of the test running (running the whole suite doesn't fail since earlier tests don't depend on the parameter and give the module time to be initialized before the scenario actually sets up a UI which does require the parameters).

Expected Behavior

All tests should be able to be run independently of any particular execution order, especially with platform parameters.

All uses of ActivityScenarioRule should be removed and replaced with manual ActivityScenario management, as shown in ProfileAndDeviceIdFragmentTest (after #5138 is merged).

Screenshots/Videos

No response

What device/emulator are you using?

N/A -- test environment

Which Android version is your device/emulator running?

N/A -- test environment

Which version of the Oppia Android app are you using?

N/A -- test environment

Additional Context

No response

BenHenning commented 4 months ago

From #5138 the classes that need to be fixed: