什么是 Google 测试、死亡测试
我看到该功能的文档似乎非常重要,因为它位于 Google 测试概述功能中,并在以下位置详细说明:
https://github.com/google/googletest/ blob/master/docs/advanced.md#death-tests
它们看起来像标准 assert()
但它们是 Google Test 的一部分,因此是 xUnit 测试框架。因此,我想知道使用这些死亡测试的真正用途或优势是什么。
I saw the documentation of that feature is seem pretty major since it's in Google Test overview features and detailed in:
https://github.com/google/googletest/blob/master/docs/advanced.md#death-tests
They look like standard assert()
but they're part of Google Test, so a xUnit testing framework. Therefore, I wonder what the real usage or advantage of using those death tests are.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
断言的作用是确认如果某个函数在当前进程中执行,该函数将导致程序终止(详细信息解释了死亡测试是从子进程调用的,该子进程允许测试在死亡的情况下继续进行)。这很有用,因为某些代码可以保证程序在失败时终止/中止(例如,如果存在不可恢复的错误),并且单元测试应确认函数遵循其记录的行为,无论可能是什么。
维基页面上的描述确实最好地解释了这一点:
The assertion is there to confirm that a function would bring about program termination if it were executed in the current process (the details explains that the death test is invoked from a subprocess which allows the tests to continue despite the death). This is useful because some code may guarantee program termination / abortion on failure (e.g. if there was an irrecoverable error), and unit tests should confirm that a function adheres to its documented behavior, regardless of what that might be.
The description on the wiki page really explains it best:
我认为您链接中的介绍很好地解释了这一点:
其中哪一点没有意义?
I thought the introduction in your link explained it fairly well:
What bit of that doesn't make sense?