我希望实现这样的目标:
[ComponentTestsModule] com.android.test
[FunctionalTestsModule] com.android.test
both depends on
-> [TestLibraryModule] ?
which depends on
-> [AppModule] com.android.application
Run Code Online (Sandbox Code Playgroud)
用android gradle插件3.0+有没有办法做到这一点?
我想要不同类型的测试的不同测试运行器,也针对不同的变体.它现在正在使用单个代码库androidTest,但在自定义测试运行器中有丑陋的开关.
我想在不同类型的测试之间共享相同的页面对象,也许是一些实用程序代码.问题是:页面对象必须能够访问R类的app(定位器:R.id.*)
我所知道的模块类型都不能依赖于APK生成模块,期望com.android.test,但我不能依赖于com.android.test另一个com.android.test.
android android-testing android-gradle-plugin android-instrumentation
根据RoboSpice文档https://github.com/octo-online/robospice/wiki/Design-of-RoboSpice,我可以在任何上下文中使用它.
无法在服务上下文中找到使用Robospice的示例.我做了一些尝试,但没有发生任何事情,请求只是没有执行,没有例外(也许一些日志泄漏,我需要做什么来启用robospice登录设备?)
一些代码
public abstract class SpicyService extends Service {
private SpiceManager spiceManager = new SpiceManager(SpiceService.class);
@Override
public void onCreate() {
super.onCreate();
spiceManager.start(this);
}
@Override
public void onDestroy() {
spiceManager.shouldStop();
super.onDestroy();
}
}
Run Code Online (Sandbox Code Playgroud) 我有这样的JUnit测试:
Test fun testCategoriesLoading() {
val subscriber = TestSubscriber<List<ACategory>>()
service.categories().subscribe(subscriber)
subscriber.awaitTerminalEvent()
subscriber.assertNoErrors()
}
Run Code Online (Sandbox Code Playgroud)
service是Retrofit,它使用GsonConverter反序列化json
data class ACategory(val id: String, val title: String, val parentId: String?, val hasChildren: Boolean)
Run Code Online (Sandbox Code Playgroud)
实例.
测试正在传递,即使ACategory填充了id = null,title = null等.
所以,据我所知,gson使用反射,kotlin懒惰地解决了第一次访问时的这种可空性限制.
有没有办法强迫这个决心?一些好看的解决方案没有手动直接访问字段?我真的不想手工编写每个断言.