简体   繁体   中英

Is there possibility to get object from MyBatis MapperProxy?

I would like to spy with Mockito if MyBatis Mapper methods are invoked and how many times, but I'm not able to do this while I'm getting the

org.apache.ibatis.binding.MapperProxy

instead of my mapper implementation. Is there any possibility to get an object from this Proxy? Or is there any other solution to spy with Mockito over Mapper methods?

MyBatis version: 3.4.1

Mockito version: 1.9.5

Spring version: 3.2.8.RELEASE

To get object from MyBatis MapperProxy is not possible, at least I didn't found any way to obtain such an object, but it is possible to spy MyBatis Mapper using annotation @SpyBean and mockito inline:

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-inline</artifactId>
    <version>${mockito.version}</version>
    <scope>test</scope>
</dependency>

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