简体   繁体   English

特浓咖啡+模拟咖啡-模拟活动启动

[英]Espresso + mockito - Mock activity launch

I'm a beginner in android tests and what I would like to know is very simple. 我是android测试的初学者,我想知道的很简单。 I have a button which launch an activity on click and instead of launching the real activity I would like to replace it by the launch of another one. 我有一个按钮,可以在单击时启动活动,而不是启动实际活动,我想用启动另一个活动来代替它。 How can I achieve that? 我该如何实现? I'm using Espresso and mockito 2.0+. 我正在使用Espresso和Mockito 2.0+。 Thank you. 谢谢。

I doubt that this question still need an answer but in cas, just know that Dependency Injection like dagger will do the job. 我怀疑这个问题仍然需要一个答案,但是在cas中,只要知道像匕首这样的依赖注入就能胜任。 Inject your real activity on your app and another activity in your test by loading a different module. 通过加载其他模块,将您的真实活动注入您的应用程序,并将另一活动注入测试中。

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

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