lundi 31 juillet 2017

How to mock behavior of a method

I have following scenario

class A {   
    Response response = someFunction()
    response.doStuff()
}

class Response {    
    fun doStuff() {
        //check if response status is OK         
        //some stuff, not to be executed when in test
    }
} 

I need to check if response is OK but not execute rest of the logic. I am looking to achieve something like -

when(response.doStuff())Then(assert response is ok)

Can you please let me know how to do this?

Aucun commentaire:

Enregistrer un commentaire