alibaba / alibaba/testable-mock
不支持在Mock类通用方法里直接使用MOCK_CONTEXT,另外Debug其全程显示为null影响排错
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
@MockMethod(targetClass = CallB.class)
public void callMe() {
fault(TestableTool.MOCK_CONTEXT);
}
private void fault(Map mc) {
mc.get("123");
// 不支持直接使用,必须传进来,而且debug MOCK_CONTEXT全程为null,导致我排错困难
// TestableTool.MOCK_CONTEXT.get("123")
}
如上例子,mock的许多方法里有共性操作,我将其提炼成一个通用方法,在通用方法里无法直接使用MOCK_CONTEXT,必须将其传参才能使用,另外debug的时候MOCK_CONTEXT全程显示为null,影响了我排错,而将其传参之后确能显示有HashMap对象了。
请求可以在另外被调方法里可以直接使用MOCK_CONTEXT,且debug的时候能显示其有对象而不是一直全程为null。
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the @MockMethod example using TestableTool.MOCK_CONTEXT in a helper method, then inspect how MOCK_CONTEXT is exposed during mocked calls and debugging. Verify that the helper can access the context directly and that the debugger shows its HashMap object rather than null.
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
- Mostly clear
- Newbie friendliness
- 35/100