alibaba / alibaba/testable-mock

测试service 中调用dao 中继承自mybatis中basemapper通用方法,mock dao层 不生效

Open
#329 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.8k
Forks
306
PR merge metrics
No merged PRs in 30d

Description

@linfan 你好,如果是service 调用 dao, dao继承mybatis中 basemapper中的通用方法 list select(T t),怎么mock,我这边在service中,@MockMethod 了dao层这个通用的select方法,但是单元测试类还是走了真实的调用请求了数据库

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reported service unit test, the mocked DAO, and the inherited MyBatis BaseMapper select(T t) call; reproduce the case and trace why the real database request is reached. Done means the DAO's inherited generic select method is intercepted in the service test and no real database call occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.