Merged
Conversation
为 MockMvcListener.beforeTestClass() 添加超时机制(默认 30 秒), 确保在服务器启动失败时能快速失败,并提供详细的故障排查建议。 关键改进: - 添加可配置的超时机制,支持 1秒至10分钟范围 - 超时抛出详细异常,包含端口号、可能原因及排查命令 - 增加 MockMvcListenerTest 单元测试,覆盖各种超时及边界场景 - 优化测试桩设计,确保在无网络环境下的测试稳定性 Fixes #395 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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