gpt4 book ai didi

android - Robolectric 间歇性 NPE 在 org.robolectric.res.ResBundle$Value.compareTo(ResBundle.java :189)

转载 作者:行者123 更新时间:2023-11-30 01:12:00 26 4
gpt4 key购买 nike

我在运行测试时出现间歇性故障。

java.lang.NullPointerException
at org.robolectric.res.ResBundle$Value.compareTo(ResBundle.java:189)
at org.robolectric.res.ResBundle$Value.compareTo(ResBundle.java:166)
at java.util.ComparableTimSort.countRunAndMakeAscending(ComparableTimSort.java:320)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:188)

在下面的代码中

@RunWith(RobolectricGradleTestRunner::class)
@Config(constants = BuildConfig::class, sdk = intArrayOf(21), packageName = "my.package")
class MyActivityTest {
lateinit var myActivity : MyActivity

@Before
fun setup() {
myActivity = MyActivity()
}
}

具体上线

        myActivity = MyActivity()

最佳答案

显然修复是

@RunWith(RobolectricGradleTestRunner::class)
@Config(constants = BuildConfig::class, sdk = intArrayOf(21), packageName = "my.package")
class MyActivityTest {
lateinit var myActivity : MyActivity

@Before
fun setup() {
myActivity = Robolectric.buildActivity(MyActivity::class.java).get()
}
}

关于android - Robolectric 间歇性 NPE 在 org.robolectric.res.ResBundle$Value.compareTo(ResBundle.java :189),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38318866/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com