如何转义函数名,使其可以跨多行?例如
@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 }
这可能吗?
这是不可能的,函数名约定允许在测试方法中使用空格,但不能多行:https://kotlinlang.org/docs/coding-conventions.html#names-for-test-methods
在测试中(且仅在测试中),您可以使用带有反引号括起来的空格的方法名。
名称中包含多行的方法即使通过反射也不能调用。(参见https://stackoverflow.com/a/45750788/7346454)