I have an Android fingerprint implementation working and I was looking to add UI tests with Espresso. One problem I can't find a solution to is how to emulate the scanning of a finger. There is an adb command
adb -e emu finger touch
which should work on emulators.
Any idea on how to integrate something like that with Espresso?
The Enroll a Fingerprint — Scan your finger screen appears. Place your finger on the fingerprint reader and wait until success is confirmed. Ensure the finger you place on the reader matches the finger you chose in the previous step. For each successful enrollment, a number will turn blue starting with 1.
From Settings, tap Biometrics and security, and then tap Fingerprints. Enter your secure screen lock credentials and then tap Add fingerprint. Follow the on-screen prompts to add the fingerprint, and then tap Done.
Espresso is a UI test framework (part of the Android Testing Support Library) that allows you to create automated UI tests for your Android app.
The Espresso Test Recorder tool lets you create UI tests for your app without writing any test code. By recording a test scenario, you can record your interactions with a device and add assertions to verify UI elements in particular snapshots of your app.
From this question sending to an emulator is possible:
Runtime.getRuntime().exec("adb -e emu finger touch 1")
I expect, though can't show any working, that faking a fingerprint on a real device would require some special kind of security magic.
Edit: this doesn't work from within espresso tests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With