Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin: Multiline function name (with backticks)

Tags:

junit

kotlin

How can I escape a function name so that it can span multiple lines? For example

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

What I would want is something like

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

Is this possible?

like image 337
TheRealFakeNews Avatar asked Jul 01 '26 04:07

TheRealFakeNews


1 Answers

It is not possible, function names convention allows spaces in test methods but not multiple lines : https://kotlinlang.org/docs/coding-conventions.html#names-for-test-methods

In tests (and only in tests), you can use method names with spaces enclosed in backticks.

A method with multiple lines in its name would not be callable even through reflection. (see https://stackoverflow.com/a/45750788/7346454)

like image 105
Thomas Martin Avatar answered Jul 04 '26 08:07

Thomas Martin