Roboelectric 3.0 testing fragments

2019-06-19 23:44发布

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条回答
Melony?
2楼-- · 2019-06-20 00:32

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

testCompile "org.robolectric:shadows-support-v4:3.0"
查看更多
登录 后发表回答