I have decided that one of the testing criteria for my application tests with Google\'s Espresso is:
Test should maintain Activity state after s
After my own troubles with testing of the orientation I want to add that while lelloman's advice to use UiDevice is correct from the documentation standpoint - unfortunately it doesn't work as expected in some cases.
I found that at least on the API 23 emulator rotation could stuck after the test's crash:
uiDevice.setOrientationLeft() UiDevice works but when test ends rotation is back the wrong one until you manually change rotation to "Auto-rotate";uiDevice.unfreezeRotation() helps while test is running but after the test's end rotation is back to the wrong one.I don't have this issue on API 28.
So I found that using setRequestedOrientation is the only solution for me.