Kotlin:多行函数名称(带反引号)

Ala*_*anH 5 junit kotlin

如何转义函数名称以便它可以跨越多行?例如

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

我想要的是类似的东西

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

这可能吗?

Tho*_*tin 2

这是不可能的,函数名称约定允许测试方法中存在空格,但不允许多行:https://kotlinlang.org/docs/coding-conventions.html#names-for-test-methods

在测试中(并且仅在测试中),您可以使用带有反引号括起来的空格的方法名称。

即使通过反射,名称中包含多行的方法也无法调用。(参见/sf/answers/3202555191/