junit Kotlin:多行函数名(带反勾号)

mm9b1k5b  于 2022-11-11  发布在  Kotlin
关注(0)|答案(1)|浏览(87)

如何对函数名进行转义,使其可以跨越多行?例如

@Test
fun `This is a really long description of what should happen to this function when the IDs do not match up.`() {
  // test
}

我想要的是

@Test
fun `This is a really long description of what should happen to this \
     function when the IDs do not match up.`() { // test }

这可能吗?

nvbavucw

nvbavucw1#

这是不可能的,函数名称约定允许在测试方法中使用空格,但不允许使用多行:https://kotlinlang.org/docs/coding-conventions.html#names-for-test-methods
在测试中(且仅在测试中),您可以使用方法名称,并将空格括在反勾号中。
名称中有多行的方法即使透过反映也无法呼叫。(请参阅https://stackoverflow.com/a/45750788/7346454

相关问题