简体   繁体   中英

Mocking local method variables with mockito / powermock

I have a method which takes in a string as a parameter.

However locally the method creates and uses a List and an instance of SingleColumnRowMapper.

Is there anyway using mockito/powermock once instances of these objects have been created/mocked in the unit test to place them as local variables into the method to be tested.

Thank You

SampleClass classInstance = Mockito.mock(SampleClass.class);

The above code mocks the instance creation of a class. If you want to create any instance, create it similarly and supply it to your method.

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