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

Testcases failing in StoryFragmentTest in Espresso #4212

Open vrajdesai78 opened 2 years ago

vrajdesai78 commented 2 years ago

The common error for all test cases:

Following test cases are failing in StoryFragmentTest with above mentioned errors:

Steps to reproduce the behavior:

  1. Run StoryFragmentTest in Espresso

Expected behavior All test cases should pass without giving any error.

Screenshot of failing test cases Screenshot from 2022-02-21 22-51-22

Environment

Rd4dev commented 2 months ago

@vrajdesai78, @adhiamboperes - Requesting Further Insight!

Is it possible that the malfunction lies with the @Config(qualifiers) annotation? These test scenarios are intended specifically for the layout-sw600dp, as depicted in the image,

image

yet they seem to be invoked even for other layouts. Despite experimenting with different versions of Robolectric, the problem persists. Are there any particular adjustments to the configurations that might resolve this issue?

I attempted to implement a manual conditional check, which proved effective.

Assume.assumeTrue(isScreenSw600dp())

private fun isScreenSw600dp(): Boolean {
    val displayMetrics = InstrumentationRegistry.getInstrumentation().targetContext.resources.displayMetrics
    val screenWidthDp = displayMetrics.widthPixels / displayMetrics.density
    return screenWidthDp >= 600
  }

Should we explore alternative methods for obtaining @Config, or consider implementing custom checks as a replacement?

With AssumeTrue Check: Screenshot (341)

Without AssumeTrue Check: Screenshot (342)