gpt4 book ai didi

unit-testing - Qt单元测试中使用qDebug

转载 作者:行者123 更新时间:2023-12-05 05:28:47 49 4
gpt4 key购买 nike

我想在 Qt 单元测试中使用 qDebug,我已经编写了 qDebug 的代码,但它没有被显示我什至用过

ctest -R alkimia-alkinvoice -VV

但即使这样也只能显示错误的来源位置。但我需要使用 qDebug 来获取有关该错误的更多信息

最佳答案

引用 qDebug() 的文档..

Calls the message handler with the debug message msg. If no message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the console, if it is a console application; otherwise, it is sent to the debugger. This function does nothing if QT_NO_DEBUG_OUTPUT was defined during compilation.

我假设您在 Windows 下运行,如果不正确,请见谅。 Windows 下的 qDebug() 输出被转换为 Win32 OutputDebugString() API 调用。如果您在可以连接到该 API 的调试器/IDE 下运行,那么您应该会在该程序的一个窗口中看到调试输出。

如果您将 CONFIG+=console 添加到您的 .pro 文件并从控制台重建/运行您的程序,您应该会看到调试输出。

关于unit-testing - Qt单元测试中使用qDebug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6960575/

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