apache / apache/servicecomb-java-chassis

TestRestClientInvocation的单元测试无法有效验证功能

Open
#3,739 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.9k
Forks
814
Avg merge
8d 23h
Merged PRs (30d)
1

Description

问题出在 `TestRestClientInvocation` 的 `testSetCseContext_enable_unicode` 方法和 `testSetCseContext_disable_unicode` 方法中, 两个方法都是开头对`invocation.getContext()`进行mock, 结尾又调用`invocation.getContext()`获取结果进行校验, 获取的结果就是mock返回, 所以达不到测试的预期效果. 1.3.x 和 2.8.x 分支均有此问题, 建议优化一下UT代码.

https://github.com/apache/servicecomb-java-chassis/blob/21d4b4863b71332f151eb63020f4e9ac51583002/transports/transport-rest/transport-rest-client/src/test/java/org/apache/servicecomb/transport/rest/client/http/TestRestClientInvocation.java#L282-L346

Contributor guide

No contributing guide indexed for this repository

Research direction

Open transport-rest/transport-rest-client/src/test/java/org/apache/servicecomb/transport/rest/client/http/TestRestClientInvocation.java and inspect testSetCseContext_enable_unicode and testSetCseContext_disable_unicode. Start by tracing how invocation.getContext() is mocked, then run these tests and confirm their assertions inspect state produced by the method rather than the mocked return value. Done means both tests meaningfully verify Unicode context behavior on the 1.3.x and 2.8.x branches.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.