How mock private method that modify private variables?
How mock private method that modify private variables? class SomeClass{ private int one; private int second; public SomeClass(){} public int calculateSomething(){ complexInitialization(); return this.one + this.second; } private void complexInitialization(){ one = ... second = ... } } You don't , because your test will depend on implementation details of the class it is testing and will therefore be brittle. You could refactor your code such that the class you are currently testing depends on another object for doing this calculation. Then you can mock this dependency of the class under test.