gpt4 book ai didi

android - 在 Android 测试中模拟 FingerprintManager

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:50:39 25 4
gpt4 key购买 nike

有没有办法模拟或模拟FingerprintManager.authenticate() ?我想为我的指纹验证器编写仪器化测试。

如果有一个解决方案限制测试可以在模拟器或设备上运行,我很好。我使用 JUnit 4.12。

最佳答案

本着 not mocking things you don't own 的精神,我可能会建议您不要 mock 它.我可能会建议什么(来自上面的链接):

The prescription implied by "don't mock what you don't own" is to introduce your own shim/wrapper/adapter around it. This effectively cordons off the dependency to a single place in your codebase and contextualizes it in the consistent and easy-to-use style you're trying to promote within your codebase. If there's anything awkward about how one needs to invoke the dependency (maybe a chaining API, multi-step invocation, repetitive default configuration, etc.), it can be swept under the rug into that common adapter.

这感觉像是 humble object pattern可能是合适的。

关于android - 在 Android 测试中模拟 FingerprintManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46053100/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com