alibaba / alibaba/testable-mock

多模块项目中使用Mock不生效的问题

Open
#262 2 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

最开始我再B模块中写测试类,可以正常Mock,但是后来我希望在测试类中能引入上下文环境,之前引入上下文环境一直使用SpringBootTest引入上下文,现在由于启动类在A模块下面,无法引入启动类,无法加载上下文环境。我想到的解决办法有两个:

(1):在A模块中编写测试类,但是Mock不生效;

(2):在B模块的测试类中引入上下文环境,但是启动类不在B模块下面。

Contributor guide

No contributing guide indexed for this repository

Research direction

Compare the two reported setups: tests in module A where Mock does not work, and tests in module B using SpringBootTest when the startup class is in module A. Start by reproducing the context-loading and mocking behavior in both modules. Done means the multi-module test setup loads the intended context and Mock works consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
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.