Do data classes need unit tests if we know they on...
# announcements
l
Do data classes need unit tests if we know they only have a primary constructor and no methods? data class(val id: String, val firstName: String, val lastName: String)
r
That depends entirely on your testing strategy.
👍 1
e
It is like
assertEquals(4, 2 + 2)
— sometimes it does make sense, but usually it does not.
💯 4
😁 1
l
I would say that data classes are already covered at many places when testing is concerned
If they have any behavior different from only keeping data, (for instance a static parse or whatever), I'd write a test for them
j
Not for unit tests. The behavior of the data class is already tested by JB at language/compiler level. Can be tested as part of integration tests