我正在尝试基于testCompile group: 'io.mockk', name: 'mockk', version: '1.7.15'
以下代码编写测试:
import io.mockk.every
import io.mockk.any
import io.mockk.Runs
import io.mockk.impl.annotations.MockK
import io.mockk.junit5.MockKExtension
@ExtendWith(MockKExtension::class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class ConfigDistributorTest {
@MockK
lateinit var configService: ...
@MockK
lateinit var centralisedConfigRegisterService: ...
val configDistributor = ConfigDistributor(centralisedConfigRegisterService, configService)
@Test
fun shouldDistributeConfigToComponents(){
every {
configService.readConfig(any())
} just Runs
}
}
虽然Runs
和已成功导入,但和MockK
不可用。是否正确的导入语句以及使用它们需要哪些其他依赖项?MockKExtension
every
any()
io.mockk.any