我使用Realm,PowerMockito和Robolectric为我的应用程序编写测试.如果我使用./gradlew test,测试运行正常,但如果我在Android Studio中运行配置.它将显示如下错误.
com.thoughtworks.xstream.converters.ConversionException: Cannot construct org.powermock.modules.junit4.rule.PowerMockStatement$1 as it does not have a no-args constructor : Cannot construct org.powermock.modules.junit4.rule.PowerMockStatement$1 as it does not have a no-args constructor
有没有人有这个问题的解决方案?这是我在Kotlin写的测试.
@RunWith(RobolectricGradleTestRunner::class)
@Config(application = TestApplication::class, constants = BuildConfig::class, sdk = intArrayOf(21))
@PowerMockIgnore("org.mockito.*", "org.robolectric.*", "android.*")
@SuppressStaticInitializationFor("io.realm.internal.Util")
@PrepareForTest(RealmCore::class, RealmLog::class, Realm::class, RealmResults::class, RealmQuery::class)
class RealmMiddlewareTest {
data class TestState(var item: List<Item> = listOf())
lateinit var realmMock: Realm
lateinit var mockRealmResults: RealmResults<Item>
val mockResults = arrayListOf(
Item().apply {
title = "item#1"
},
Item().apply {
title …Run Code Online (Sandbox Code Playgroud)