fix: 修复 MockMvcListener 无限等待导致测试卡死问题 #397
Merged
+512
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔗 相关问题 / Related Issue
Issue 链接 / Issue Link: #395
📋 变更类型 / Type of Change
📝 变更目的 / Purpose of the Change
修复 MockMvcListener 在等待 Mock MVC 服务器启动时无限等待的问题。当服务器因端口占用或其他原因无法启动时,测试会永久卡死而不是快速失败并提供明确的错误信息。
📋 主要变更 / Brief Changelog
fit.test.mockmvc.startup.timeout自定义超时时间isStarted()方法的可见性改为protected以便测试🧪 验证变更 / Verifying this Change
测试步骤 / Test Steps
mvn test -Dtest=MockMvcListenerTest测试覆盖 / Test Coverage
新增测试覆盖:
shouldTimeoutWhenServerNotStarted: 验证超时机制shouldStartWhenServerAvailable: 验证延迟启动场景shouldFallbackToDefaultTimeoutWhenInvalidConfig: 验证非法配置处理shouldFallbackToDefaultWhenNegativeTimeout: 验证负数配置处理shouldFallbackToDefaultWhenZeroTimeout: 验证零值配置处理shouldClampWhenTooLargeTimeout: 验证超大值配置处理📸 截图 / Screenshots
N/A
✅ 贡献者检查清单 / Contributor Checklist
基本要求 / Basic Requirements:
代码质量 / Code Quality:
测试要求 / Testing Requirements:
mvn -B clean package -Dmaven.test.skip=true/ Basic checks passmvn clean install/ Unit tests pass文档和兼容性 / Documentation and Compatibility:
📋 附加信息 / Additional Notes
设计考虑
影响范围
@EnableMockMvc注解的测试类审查者注意事项 / Reviewer Notes:
🤖 Generated with Claude Code