I need to mock a java class that has a private constructor and only a static create method.
What would be the typical solution in that kind of situation.
With or without a framework.
I need to mock a java class that has a private constructor and only a static create method.
What would be the typical solution in that kind of situation.
With or without a framework.
You can use PowerMock to mock static methods https://code.google.com/p/powermock/wiki/MockitoUsage, so you would mock the static create method and return whatever you want. It's easier if the static method returns an interface rather than a class so you can return your own mock implementation of it.