相关疑难解决方法(0)

如何在java中模拟单个方法

是否可以模拟Java类的单个方法?

例如:

class A {
    long method1();
    String method2();
    int method3();
}


// in some other class
class B {
    void someMethod(A a) {
       // how would I mock A.method1(...) such that a.method1() returns a value of my
       // choosing;
       // whilst leaving a.method2() and a.method3() untouched.
    }
}
Run Code Online (Sandbox Code Playgroud)

java mocking

30
推荐指数
3
解决办法
5万
查看次数

标签 统计

java ×1

mocking ×1