如何解决使用 PowerMockito 测试 Android 原生代码
我在测试继承 android 本机类的自定义 TTS 类时遇到以下异常:
java.lang.UnsupportedOperationException: getNativeBBinderHolder is native
at android.os.Binder.getNativeBBinderHolder(Binder.java)
at android.os.Binder.<init>(Binder.java:597)
at android.os.Binder.<init>(Binder.java:581)
at android.speech.tts.ITextToSpeechService$Stub.<init>(ITextToSpeechService.java:230)
at android.speech.tts.TextToSpeechService$1.<init>(TextToSpeechService.java:1275)
at android.speech.tts.TextToSpeechService.<init>(TextToSpeechService.java:1274)
at com.speech.speechimpl.tts.TtsServiceImplBase.<init>(TtsServiceImplBase.java:11)
at com.speech.assistant.core.impl.tts.TtsServiceImpl.<init>(TtsServiceImpl.java:20)
at com.speech.assistant.core.impl.tts.SpeechImplTest.testSpeechOnStop(SpeechImplTest.java:66)
源代码 - SpeechImplTest.java
Line 66 : mSpeechImpl = new SpeechImpl();
Line 67 : mSpeechImplSpy = spy( mSpeechImpl );
using annotation
@SuppressStaticInitializationFor({"android.os.SystemProperties","android.os.Binder"})
如何解决这个问题?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。