如何模拟匕首活动对象图?匕首、对象

由网友(掩于岁月)分享简介:我用匕首在一个Android应用程序提供应用和活动范围图。而我使用Robolectric进行单元测试。我知道,我可以提供Robolectric与配置了覆盖真正的与嘲笑的应用程序对象图的替代应用程序类。但我难倒,如何与活动对象图做同样的,因为标准模式活动对象图是对活动本身来实例化所需的特定活动的匕首模块。任何建议,将不胜...

我用匕首在一个Android应用程序提供应用和活动范围图。而我使用Robolectric进行单元测试。我知道,我可以提供Robolectric与配置了覆盖真正的与嘲笑的应用程序对象图的替代应用程序类。但我难倒,如何与活动对象图做同样的,因为标准模式活动对象图是对活动本身来实例化所需的特定活动的匕首模块。任何建议,将不胜AP preciated。

I'm using Dagger in an android app to provide application and activity scope graphs. And I'm using Robolectric for unit-testing. I know that I can provide Robolectric with a substitute Application class that is configured with an application object graph that overrides the real one with mocks. But I'm stumped as to how to do the same with the activity object graphs since the standard pattern for activity object graphs is for the activities themselves to instantiate the activity-specific Dagger module they need. Any suggestions would be greatly appreciated.

推荐答案

请看看我的项目 - 的https: //github.com/emartynov/UrlSetter

Please take a look to my project - https://github.com/emartynov/UrlSetter

您会发现我是如何设法用嘲弄与匕首 Robolectric 测试

You will find how I managed to use mocks with Dagger in Robolectric tests

阅读全文

相关推荐

最新文章