jas*_*nte 6 junit android hamcrest kotlin
org.hamcrest.Matchers当我根据需要导入时,无法运行单元测试lessThan()。我的仪器测试在使用greaterThan匹配器时可以正确编译,但不能在单元测试中正确编译
代码:
import org.hamcrest.CoreMatchers.*
import org.hamcrest.Matchers.lessThan
import org.junit.Assert.assertThat
import org.junit.Test
import java.util.*
Run Code Online (Sandbox Code Playgroud)
Gradle 日志: https: //pastebin.com/ibgzzrg1
删除第二行会使项目编译并运行测试。
我也有同样的问题。我发现我只在仪器测试中遇到这个问题。非仪器测试能够导入并运行良好。
对我来说解决这个问题的是添加androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'我的依赖项。
我已经删除了这个想法,认为这是没有必要的,因为我的测试都没有明确使用 Espresso。事实证明确实如此,原因超出了我的理解。
| 归档时间: |
|
| 查看次数: |
2963 次 |
| 最近记录: |