Visual Studio和Boost :: Test [英] Visual Studio and Boost::Test
问题描述
我开始使用Boost :: Test驱动的开发(在C ++中),我正在使用单元测试来翻新我的一个旧项目。我的问题是 - 我在哪里添加单元测试代码?测试本身的语法看起来真的很简单,根据Boost :: Test的文档,但我很困惑,如何告诉编译器生成可执行文件与我的单元测试。理想情况下,我将使用一个预编译头和boost :: test库的头文件版本。
I'm getting started with Boost::Test driven development (in C++), and I'm retrofitting one of my older projects with Unit Tests. My question is -- where do I add the unit test code? The syntax for the tests themselves seems really simple according to Boost::Test's documentation, but I'm confused as to how I tell the compiler to generate the executable with my unit tests. Ideally, I'd use a precompiled header and the header-only version of the boost::test library.
我只是创建一个新的测试项目,并添加所有我的现有源文件到它?
Do I just create a new project for tests and add all my existing source files to it?
Billy3
推荐答案
我已经添加Boost单元测试到现有的解决方案是创建新的项目,并把测试代码在这些项目。你不需要担心创建main()函数或设置测试。 Boost会照顾所有这些。
They way I've added Boost unit tests to existing solutions was to create new projects and put the test code in those projects. You don't need to worry about creating a main() function or setting up the tests. Boost takes care of all that for you.
这里是项目我使用Boost进行单元测试的Google代码。
Here is a project I put on Google Code that uses Boost for its unit tests.
这篇关于Visual Studio和Boost :: Test的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!