How to override a method in unit tests that is called from which the class being tested
问题 I am testing a class A's function func1. Func1 has a local variable of Class B and calls B's function func2. Code looks something like this: public Class A { public func1() { B object = new B(); int x = object.func2(something); } } When I am testing func1 in its unit tests, I don't want func2 to get called. So I am trying to do something like this in the test: B textObject = new B() { @override int func2(something) { return 5; } } But it is still calling the func2 in the class B. Please