MockK, the idiomatic mocking framework for Kotlin (Yannick De Turck)

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 7

  • @avikchowdhury6933
    @avikchowdhury6933 2 года назад +1

    great presentation, explaining core features of mockk. Great work!!

  • @roymath
    @roymath 3 года назад

    Excellent presentation. Thank you

  • @astatalol
    @astatalol 2 года назад

    Useful to this day, thank you sir

  • @mytubekt
    @mytubekt 2 года назад

    Thanks!

  • @kartikayy
    @kartikayy 5 лет назад

    How to spy final methods using mockk ? Every time i have to wrap it with an open method to spy a final method

  • @91whoiswho
    @91whoiswho 3 года назад

    Good one!

  • @shruthiranganatha7333
    @shruthiranganatha7333 4 года назад

    I am trying to implement the same given below using MockK instead of Mockito. I am not able to mock the lambda function inside the JDBC template update() method
    class Repository(private val jdbcTemplate: JdbcTemplate) {
    createRule(emp: Employee): Int? {
    val insertRuleQuery: String = getAddEmployeeSqlString()
    val holder: KeyHolder = GeneratedKeyHolder()
    val row: Int = jdbcTemplate.update({ connection: Connection ->
    val ps = connection.prepareStatement(insertRuleQuery, arrayOf("EMP_ID"))
    ps.setLong(1, emp.batchId)
    ps.setString(2, emp.permanent)
    ps.setString(3, emp.groupId)
    ps
    }, holder)
    return row
    }
    class RepositoryTest {
    private val mockJT = Mockito.mock(JdbcTemplate::class.java)
    fun `jdbc test emp insert`() {

    Mockito.`when`(
    mockJT.update(
    Mockito.any(PreparedStatementCreator::class.java), Mockito.any(
    KeyHolder::class.java
    )
    )
    ).thenReturn(1)
    assertEquals(count, 1)
    }