简体   繁体   中英

EasyMock for injecting mocks and mock private method f

I'm writing Testcases using EasyMock. My use case is

  1. I need to do injecting mocks and
  2. mock private method(method of the class to be tested) call .

I searched internet and found injecting mocks can be done using EasyMockRunner . and private method call can be mocked using PowerMockRunner . And compiler is not allowing to add 2 runners on same testclass. I'm not able to find any other way to do these 2 things.

Any suggestions on other ways to achieve them are most welcome and appreciated.

I achieved injecting mocks using Whitebox.setInternalState(spiedMockObject,"attribute_tobeinjected",mockedValueToinject);

and sideways I could call private methods using PowerMock without any hassles.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM