Skip to content
Advertisement

How to mock private method using powermock?

If I have a simple class like:

JavaScript

What modification do I need to mock the private method getDefaultLuckyNumber? I have this which doesnt work

JavaScript

Advertisement

Answer

PowerMock annotations required for mock working:

JavaScript

Example of working test:

JavaScript

PowerMock version:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement