Roboelectric 3.0 testing fragments

不羁的心 提交于 2019-12-08 19:43:50

问题


I am new to Roboelectric testing. I am trying to follow this post to test fragments. I am using following as dependency

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile "org.robolectric:robolectric:3.0"
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:support-v4:22.1.0'
compile 'com.google.android.gms:play-services:7.5.0'

}

But this import is giving me compilation issues, and I am not able to resolve the symbol SupportFragmentTestUtil to start with. Kindly guide me what I am missing??

org.robolectric.shadows.support.v4.SupportFragmentTestUtil

回答1:


You need to add the dependency for v4 shadows support. Add this in your dependency file.

testCompile "org.robolectric:shadows-support-v4:3.0"


来源:https://stackoverflow.com/questions/31869269/roboelectric-3-0-testing-fragments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!