How do I make Visual Studio pause after executing a console application in debug mode?(在调试模式下执行控制台应用程序后,如何让 Visual Studio 暂停?)
问题描述
我有一组 Boost 单元测试,我想作为控制台应用程序运行.
I have a collection of Boost unit tests I want to run as a console application.
当我处理项目并运行测试时,我希望能够调试测试,并且希望在测试运行后控制台保持打开状态.
When I'm working on the project and I run the tests I would like to be able to debug the tests, and I would like to have the console stay open after the tests run.
我看到如果我在发布模式下运行,控制台窗口会在程序退出后保持不变,但在调试模式下则不是这样.
I see that if I run in release mode the console window stays up after the program exits, but in debug mode this is not the case.
我不想添加'system("pause");'或任何其他技巧,例如在我的程序中读取字符.我只想在运行调试测试后让 Visual Studio 暂停,就像我在发布模式下运行一样.如果在 Visual Studio 的输出窗口之一中捕获测试的输出,我也希望这样做,但这似乎也比应有的困难.
I do not want to add 'system("pause");' or any other hacks like reading a character to my program. I just want to make Visual Studio pause after running the tests with debugging like it would if I were running in release mode. I would also like it if the output of tests were captured in one of Visual Studio's output windows, but that also seems to be harder than it should be.
我该怎么做?
推荐答案
Boost 测试提供以下内容 Visual Studio 的使用建议 使您能够在编译结束时自动运行单元测试并捕获输出进入构建窗口.
Boost test offers the following usage recommendations for Visual Studio that would enable you to run the unit tests automatically at the end of compilation and capture the output into the build window.
这个技巧的一个很好的副作用是它使您能够将测试失败视为编译错误....您可以使用通常用于编译错误分析的键盘快捷键/鼠标点击来跳过这些错误..."
The nice side effect of this trick is it enable you to treat test failures as compilation errors. "...you could jump through these errors using usual keyboard shortcuts/mouse clicks you use for compilation error analysis..."
这篇关于在调试模式下执行控制台应用程序后,如何让 Visual Studio 暂停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在调试模式下执行控制台应用程序后,如何让 Visual Studio 暂停?
基础教程推荐
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07