/powermock-whennew-capturing

Example which shows that whenNew does not capture correctly same type objects

Primary LanguageJava

PowerMock whenNew and capturing same type objects issue

This is a MCVE which shows that using PowerMock.whenNew method, when capturing same types objects (in the example, are both String's), are not captured correctly, and mathes both in the first capturer.

There is the domain object which has multiple constructors and a static factory method. The unit tests tries to mock constructor and invoking the factory method. It is matched as the mock object is returned, but not correctly captured.

Switch version

I've found the issue using 1.6.2 version, but switching the build.gradle version to 1.6.4 and executing

gradlew test

Unit test fails too.