the code is easy as ```import io.mockk.every impor...
# mockk
t
the code is easy as
Copy code
import io.mockk.every
import io.mockk.mockk
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
import javax.persistence.Entity
import javax.persistence.Id

@Entity
data class FooEntity(@Id val id: Long)

@Repository
interface FooRepository : JpaRepository<FooEntity, Long>

class Footest {

    private val fooRepository = mockk<FooRepository>()

    @BeforeEach
    fun setUp() {
        every { fooRepository.save(any()) } throws RuntimeException()
    }

    @Test
    fun test() {
        val fooEntity = FooEntity(4321)
        print(fooEntity.id)
    }
}
stepping though the code reveals that i end up in a mockk proxy accessing the
fooEntity.id