Tag: 境界

使用Realm + PowerMockito无法在Android Studio中运行Robolectric测试

我使用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 […]