facebook / screenshot-tests-for-android

Generate fast deterministic screenshots during Android instrumentation tests
http://facebook.github.io/screenshot-tests-for-android
Apache License 2.0
1.74k stars 229 forks source link

Get temp directory with pulled screenshots #230

Closed lwasyl closed 4 years ago

lwasyl commented 4 years ago

As part of CI I'd like to not only see the HTML report which uses tiled screenshots, but also archive screenshots pulled from the device in the same format as those saved by record tasks. That is, I'd like to temporarily archive files against which screenshots in the repository are verified. I can see it's some sort of temporary folder, typically something like /var/folders/kt/2gw0pl_17bdc4xffpt1099x00000gn/T/tmpOq13_2/. Can I somehow set or access this via Gradle so that I'm able to archive its contents?

lwasyl commented 4 years ago

I have since read the documentation and noticed referenceDir option on Gradle extension. However using it e.g. like referenceDir = rootProject.file("build/test-results/instrumentation/screenshot-tests") just creates background.png, background_dark.png, default.css and default.js files inside the requested directory and nothing else, and the verify task failes in _validate_medatada with IOError: [Errno 2] No such file or directory: u'/Users/wasyl/projects/talent-app/build/test-results/instrumentation/screenshot-tests/metadata.xml'.

It's all weird, I'd expect no files other than full-sized screenshots in the given directory anyway. None of the tasks I ran does anything meaningful there - everythin either fails or uses other directories.

lwasyl commented 4 years ago

The underlying issue is fixed as of 0.11.0 since failures are now recorded in a specified directory. Since for non-failures the screenshots are guaranteed to be the same, I now have all that I needed