简体   繁体   English

是否可以在 Robolectric 单元测试中运行 ML Kit?

[英]Is it possible to run ML Kit in Robolectric unit tests?

I'm curious whether it's possible to run Google ML Kit in Robolectric unit tests.我很好奇是否可以在Robolectric单元测试中运行Google ML Kit If I try, I get the following error:如果我尝试,我会收到以下错误:

java.lang.IllegalStateException: MlKitContext has not been initialized java.lang.IllegalStateException:MlKitContext 尚未初始化

The same test runs perfectly if I run it as an instrumented test (with AndroidJUnit4).如果我将其作为仪器测试(使用 AndroidJUnit4)运行,则相同的测试可以完美运行。

Please use androidTest instead.请改用 androidTest。

is the official answer from Google是谷歌的官方回答

ref: https://github.com/googlesamples/mlkit/issues/251参考: https://github.com/googlesamples/mlkit/issues/251

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM