User:CFeng (WMF)/EspressoTest with Screenshots Comparison

From mediawiki.org

Preparation

  1. An Android device, API >= 19
  2. A File Manager app

Setup

  1. After installing the app, go to the App Info => Permissions to enable the Storage permission
  2. Run the app/src/androidTest/java/org/wikipedia/espresso/SampleOfTests.java to generate references (screenshots)
  3. Use the File Manager app to find the generated references, which should be exported to [EXTERNAL STORAGE]/wikipedia-app-tests/
  4. Copy the references into the Wikipedia Android app assets folder: [PATH_OF_PROJECT]/app/src/main/assets/espresso
 If you cannot find the folder or cannot find any files inside the folder, please make sure the Storage Permission has been enabled.

Test

  1. Run the app/src/androidTest/java/org/wikipedia/espresso/SampleOfTests.java again
  2. Check the console to see the results of screenshot comparison

Notes

  1. If we need to test other pages (e.g.: Article page, Reading Lists page), please make sure the Network status is stable and every step should be only processed after the current page is loaded completely
  2. The resolution of the references and screenshots should be the same, otherwise, the comparison will be meaningless.
  3. Automatically grants the Storage permission should be considered as an improvement.
  4. Lower quality of screenshots should be also considered as an improvement.

Links

  1. Reference ticket: https://phabricator.wikimedia.org/T176860

  2. Patch of sample codes: https://gerrit.wikimedia.org/r/#/c/394735/

  3. Sample of reference images: https://drive.google.com/drive/folders/1IeeywkDGLs7ZmRlifvpTwnDXTAsyg2Xc?usp=sharing