JUnit mocking with Mockito, EasyMock, etc
问题 I'm trying to mock a method of an object inside the class I'm testing. For instance class ClassToTest { public doSomething () { SomeObject a = new SomeObject (); a.doSomethingElse (); } } Is there a way to mock the methods of the variable "a"? I'd like doSomethingElse to do nothing during testing. I'm currently using Mockito but I'm open to any mocking framework. Thanks 回答1: Yes, there is a way, as shown by the following JMockit test: public void testDoSomething(final SomeObject mock) { new