<https://mockk.io/> version 1.9.1 besides a few bu...
# feed
o
https://mockk.io/ version 1.9.1 besides a few bug fixes brings us two interesting features: Hierarchical mocking: https://mockk.io/#hierarchical-mocking Better vararg support: https://mockk.io/#varargs (all the rest: https://github.com/mockk/mockk/releases/tag/1.9.1) Example of hierarchical mocking:
Copy code
interface AddressBook {
    val contacts: List<Contact>
}

interface Contact {
    val name: String
    val telephone: String
    val address: Address
}

interface Address {
    val city: String
    val zip: String
}

val addressBook = mockk<AddressBook> {
    every { contacts } returns listOf(
        mockk {
            every { name } returns "John"
            every { telephone } returns "123-456-789"
            every { address.city } returns "New-York"
            every { address.zip } returns "123-45"
        },
        mockk {
            every { name } returns "Alex"
            every { telephone } returns "789-456-123"
            every { address } returns mockk {
                every { city } returns "Wroclaw"
                every { zip } returns "543-21"
            }
        }
    )
}
🎉 4
👍 3