在调试模式下执行控制台应用程序后,如何让 Visual Studio 暂停?

How do I make Visual Studio pause after executing a console application in debug mode?(在调试模式下执行控制台应用程序后,如何让 Visual Studio 暂停?)

本文介绍了在调试模式下执行控制台应用程序后,如何让 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 暂停?

基础教程推荐