防止提交未通过单元测试的代码(eclipse 和 Perforce)
我们希望在允许开发人员提交之前验证已提交的代码是否没有失败的单元测试。 您知道有什么工具可以帮助我们吗?
We want to verify that there are no unit tests for the committed code that fails before allowing the developers to commit.
Do you know any tool that will help us?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议不要这样做,因为在实践中,有时您希望允许开发人员提交未通过所有单元测试的代码。另外,请考虑开发人员可能会尝试通过删除单元测试或首先不编写单元测试来解决该限制。
该工具如何确定所有 unot 测试都已通过?它必须构建代码并运行单元测试套件。因此,构建环境或测试套件中的错误可能会导致无法签入代码。
I'd recommend against doing this, because in practice there are times when you want to allow developers to submit code that does not pass all its unit tests. Also, consider that developers might try to work around the restriction by deleting unit tests, or by not writing them in the first place.
And how could the tool determine that all unot tests passed? It would have to build the code and run the unit test-suite. A fault in the build environment or the test-suite might therefore make it impossible to check-in code.