alibaba / alibaba/testable-mock

抽象父类中调用mapper时如何mock

Open
#246 4 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

增删改查太多,把常用的处理逻辑写在了抽象父类。
场景是这样,AServiceImpl实现了AService接口,继承了AbstractService抽象类,AServiceImpl部分方法直接super调用。
AbstractService通过AServiceImpl重写的getMapper方法获得相应mapper的引用,然后调用mapper的相关方法。
我在测试AServiceImpl相关方法的时候,尝试mock mapper的相关方法,但是不起作用,而且日志里也没有打印抽象类内部的调用链路。请问是我的操作有问题吗?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the AServiceImpl test scenario described in the issue, then trace AbstractService#getMapper and the mapper calls reached through super. Reproduce the mock setup and inspect whether the abstract-class call path is exercised; done means the cause of the ineffective mock and missing logs is demonstrated by a focused test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
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.