【发布时间】:2019-08-15 20:35:10
【问题描述】:
我无法在不需要 robolectric 的情况下创建单元测试。我在我的代码中使用 AndroidThreeTen.init(this) 并且当我运行我的测试时,如果我禁用 robolectric 我会得到一个错误:
org.threeten.bp.zone.ZoneRulesException: No time-zone data files registered
如果我启用它,我会得到:
[Robolectric] com.mycomp.,yapp.utilities.log.LogTest.on Calling function w it returns an Int: sdk=28; resources=BINARY
我尝试过使用 testImplementation 'com.jakewharton.threetenabp:threetenabp:1.1.0' 没有任何区别。我在我的应用程序和 testApplication 中调用了 AndroidThreeTen.init(this)。有任何想法吗? 这是我的测试
@Test
fun `on Calling function i it returns an Int`() {
assertThat("Returned class is not an Int", Log.i("Test", "Test"), isA(Int::class.java))
assertThat("Returned Int is not 0", Log.i("Test", "Test"), `is`(0))
}
或者我是否因此必须使用 robolectric? (旁注:日志不是来自android的util.log,而是我自己的类)(已编辑)
【问题讨论】:
标签: android unit-testing testing kotlin robolectric