https://kotlinlang.org logo
#kotest
Title
# kotest
s

snowe

02/23/2022, 9:18 PM
really strange issue with datatest and the intellij plugin. If I use
Int
as the type here, the tests render in the run panel correctly. But if I switch to
Number
, the tests render indexed, without parameters displayed, also it shows the FQDN rather than just the
Adder
name.
oh, and it also throws warnings due to the same test name
Copy code
WARN: Duplicated test name com.sunrun.pricing.flex.BaseAdder. To disable this message, set DuplicateTestNameMode to None.
e

Emil Kantis

02/23/2022, 9:32 PM
Seems to be due to
Number
not being considered a primitive when checking if it’s stable to use for generating names. Maybe it should be - any implementation of
Number
must be a platform primitive, right?
🤔 nvm, anything can implement it so I suppose it makes sense https://github.com/kotest/kotest/blob/master/kotest-framework/kotest-framework-api/src/commonMain/kotlin/io/kotest/core/test/Identifiers.kt https://github.com/kotest/kotest/blob/master/kotest-common/src/commonMain/kotlin/io/kotest/mpp/stable.kt
You could perhaps provide the
nameFn
explicitly, like
Copy code
withData {
  nameFn = BaseAdder::toString,
  BaseAdder(..),
  ..
s

snowe

02/23/2022, 10:01 PM
@Emil Kantis that worked! interesting. not sure I understand why that worked though.
e

Emil Kantis

02/23/2022, 10:48 PM
I think this page explains it better than I could 🙂
s

snowe

02/24/2022, 12:16 AM
Kotest will only use the toString() of the input class if it thinks the input class has a stable toString() value otherwise it will use the class name.
ah. that does explain it.
35 Views