I wish to unit test classes that contain fields. Because of the fact that it is unit tests, all dependencies should be mocked. Let's say that I have the classes
public class A {
public B b = new B();
}
public class B {
}
How would you mock public/private class fields? Like when unit testing some method in A
hat uses b
, you would have to mock B
to test the class in isolation from its real dependencies - but how?