User:CFeng (WMF)/EspressoTest with Screenshots Comparison
Preparation
- An Android device, API >= 19
- A File Manager app
Setup
- After installing the app, go to the App Info => Permissions to enable the Storage permission
- Run the
app/src/androidTest/java/org/wikipedia/espresso/SampleOfTests.java
to generate references (screenshots) - Use the File Manager app to find the generated references, which should be exported to
[EXTERNAL STORAGE]/wikipedia-app-tests/
- 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
- Run the
app/src/androidTest/java/org/wikipedia/espresso/SampleOfTests.java
again - Check the console to see the results of screenshot comparison
Notes
- 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
- The resolution of the references and screenshots should be the same, otherwise, the comparison will be meaningless.
- Automatically grants the Storage permission should be considered as an improvement.
- Lower quality of screenshots should be also considered as an improvement.
Links
Reference ticket: https://phabricator.wikimedia.org/T176860
Patch of sample codes: https://gerrit.wikimedia.org/r/#/c/394735/
Sample of reference images: https://drive.google.com/drive/folders/1IeeywkDGLs7ZmRlifvpTwnDXTAsyg2Xc?usp=sharing