kotest / kotest

Powerful, elegant and flexible test framework for Kotlin with additional assertions, property testing and data driven testing
https://kotest.io
Apache License 2.0
4.36k stars 628 forks source link

shouldBeEqualToComparingFields not working with generic fields #4151

Open luisttk opened 1 week ago

luisttk commented 1 week ago

Using Kotest 5.8.1

The following test fails:


data class ParameterValue<T : Any>(val name: String, val value: T)

class TestCase : ShouldSpec({

    should("consider them different") {
        ParameterValue("Test Param", "value") shouldNotBeEqualToComparingFields
                ParameterValue("Test Param", "well well")
    }

})

shouldBeEqualToComparingFields shows the same behaviour. If shouldBe is used or value is replaced with a regular String in the class definition the test works.

AlexCue987 commented 1 week ago

I'll take a look.