anticafe
anticafe

Reputation: 6892

How to mock super method by MockK

Assuming we have Activity.onCreate() like this

class MyActivity : AppCompatActivity() {

    fun doSomething() {}

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        doSomething()
    }
}

I want to use MockK to verify if onCreate() is invoked, then doSomething() is invoked too. However I don't know how to mock the super.onCreate() method.

Do you know any solution for this?

Upvotes: 4

Views: 2203

Answers (1)

Fabio Torchetti
Fabio Torchetti

Reputation: 206

From what I see at https://github.com/mockk/mockk/issues/607 it seems currently unsupported - or not working.

The issue shows the Mockito way of solving this.

Upvotes: 2

Related Questions