Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android UI test Fingerprint with Espresso

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?

like image 798
QuirijnGB Avatar asked Feb 23 '16 15:02

QuirijnGB


People also ask

How do you test a fingerprint sensor?

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.

How do you check fingerprint on Android?

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.

What is Espresso UI Test?

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.

What is espresso testing in Android?

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.


1 Answers

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.

like image 150
jamesh Avatar answered Sep 22 '22 07:09

jamesh