Understanding Mockito's Type Inference Trick in the mock() Method
Recently, I nearly misinterpreted code authored by a team member contrary to its intended purpose. The implementation initially appeared counterintuitive, prompting thorough reinvestigation documented herein. The team member’s code utilized generics for creating a method applicable to API invocations in a versatile manner. The explanation referenced employing an identical technique to Mockito library’s mock() method, warranting examination. Type Inference in Mockito’s mock() (Version: mockito-core 4.9 or higher, included in spring-boot-starter-test from 3.1 onwards) ...