would it be useful/cool to have an arb that genera...
# kotest
a
would it be useful/cool to have an arb that generates values from a Kotlinx Serialization KSerializer? It's a bit of a nicer, more automatic way of creating binds, without having to define Arbs for all the fields in a target class.
e
Iirc there's already automatic arbs for data classes (containing primitives or other data classes). How would you use the serializer?
a
ah, okay, I didn't see any automatic data class arbs. Do you know where it is? What do you mean, 'use the serializer'? At the moment I made an extension function on KSerializer that returns an arb
Copy code
val personArb = Person.serializer().arb()
I meant - How does the extension function work? Do you use the serial descriptor somehow to generate the class? 🤔
a
ahhh yes, here's the code (I forgot to attach it). It's more of a POC at the mo. I think it could be made more useful, like making it shrinkable
ah okay, yes this is similar to jvmbind.kt. Except it works on any
@Serializable
class, and is multiplatform.
e
Yeah, the fact that it is available for multiplatform is awesome imo. Biggest drawback is perhaps that it wouldn’t generate edge cases for underlying arbs?
a
as written, it doesn't do anything clever. No shrinks, no edgecases. I think it would be possible though. Instead of directly generating values from arbs, there would have to be something intermediate to make ArbDecoder get values from edgecases/shrinks