有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何模拟方法的行为

我有以下几种情况

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
    }
} 

我需要检查响应是否正常,但不执行其余的逻辑。 我希望能实现以下目标:

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

你能告诉我怎么做吗


共 (0) 个答案