mercredi 25 juillet 2018

Kotlin: Access private var in test

I have a Kotlin class containing the following property

private var items: List<Item> = listOf()

In my test I now want to check if there are items in the list. I try to do this with reflection:

val field = sut::class.members.findLast { f -> f.name.equals("items") }

I now get a KCallable<*> back but I don't know how I can access or at least count the items in my list.





Aucun commentaire:

Enregistrer un commentaire