https://kotlinlang.org logo
#getting-started
Title
# getting-started
s

savrov

09/22/2021, 11:05 PM
hello, i tried to google, but did not find anything. a want to make a real long fun name for my unit test, but met an error (screenshot) It happens only with a really long name of fun. Can i overcome it somehow?
j

Joffrey

09/22/2021, 11:08 PM
It looks like you have some sort of class inside the function (maybe a lambda) and the problem is writing the compiled code of that class to a
.class
file. Maybe the OS doesn't support that name length? (that, or maybe an actual permission issue?)
e

ephemient

09/22/2021, 11:18 PM
macos and windows filenames are limited to around 255 characters, and the classname there exceeds the limit by a lot
j

Joffrey

09/22/2021, 11:20 PM
But anyway the real question is... are you serious about that test function name? 😄
s

savrov

09/22/2021, 11:20 PM
@Joffrey i think u are right. just tried to create a folder with a such name in xos and it failed
it could be much easier for me to maintain these tests. mb im wrong. any way i should to fix naming now 🙂
p

Paul Griffith

09/22/2021, 11:35 PM
what test framework? e.g. JUnit has `@DisplayName`https://junit.org/junit5/docs/current/user-guide/#writing-tests-display-names that might not be part of the literal class output
e

ephemient

09/23/2021, 2:16 AM
anyhow, there is a ticket https://youtrack.jetbrains.com/issue/KT-17433 but no resolution, so please avoid excessively long names or excessive nesting
t

thanksforallthefish

09/23/2021, 7:14 AM
have a look at kotest maybe, there you more test styles available you do something like
Copy code
given("a single resource with both data sources") {
  `when`("always read policy"){
    and("query query from single resource from local data source failed") {
      //you get the gist
    }
  }
}
https://github.com/kotest/kotest/blob/master/doc/styles.md#behavior-spec the level of nesting would depend on which scenarios you are testing, it could help with reusability of code as well. might help you with this long complex and descriptive approach
and if you are not aware, #kotest is here as well
5 Views