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

查看:317
本文介绍了在调试模式下执行控制台应用程序后,如何使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 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暂停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆