gpt4 book ai didi

testing - 登录自动化测试

转载 作者:行者123 更新时间:2023-11-28 20:40:17 24 4
gpt4 key购买 nike

是否有理由在自动化测试中使用日志记录?我问是因为我知道测试必须是可读的,你不应该使用任何日志记录来膨胀代码。它还用于了解应用程序中发生的事情,所以如果它失败了,我知道为什么(断言消息),如果没有 - 好吧,我不关心测试中的内容。

提前致谢。

最佳答案

你说的对

test must be readable

因为测试码是production code .而且质量应该很高,如果不一样的话。但是恕我直言

shouldn't use any logging to bloat the code.

不正确。如果您在远程(物理或 VM)服务器上运行自动化测试,您需要一些方法来了解每个步骤中发生了什么,错误和警告在哪里。

如何仅使用堆栈跟踪和最新的断言消息来解决或重现失败的测试?日志记录可帮助您避免 Obscure Test 的常见原因- Mystery Guest .您应该能够毫不费力地看到夹具和验证逻辑之间的因果关系。我们来看看Log4j home page

Logging equips the developer with detailed context for application failures. On the other hand, testing provides quality assurance and confidence in the application. Logging and testing should not be confused. They are complementary. When logging is wisely used, it can prove to be an essential tool.

我希望到现在为止,我已经设法说服至少一个人日志记录是自动化测试的基本组成部分。

关于testing - 登录自动化测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36258849/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com