且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

整装使用Boost.Test入门

更新时间:2023-12-01 09:26:46

BOOST.Test非常灵活,你也许可以做你想做的。不过既然你说你是新来的单元测试,你应该遵循标准的单元测试结构。

BOOST.Test is very flexible and you can probably do what you want. However since you say you are new to unit testing, you should probably follow the standard unit testing structure.

这是对每一个项目你是单元测试一个单独的测试项目。然后包括你需要建立测试项目的源代码和库。

This is to have a separate test project for each project you are unit testing. Then include the sources and libraries you need to build the test project.

这是由于清洁剂中有你的主要项目中没有测试逻辑可能会得到意外地运行,这是容易,因为他们有自己的可执行文件来运行测试。这种方法也适用于检测库。如果按照这个结构,你会发现,大部分的BOOST.Test默认的工作开箱即用,你可以只是担心你编写的测试和code。

This is cleaner as there are no test logic in your main project that might get run accidentally and it is easy to run the tests as they have their own executable. This approach also works for testing libraries. If you follow this structure you will find that most of the BOOST.Test defaults work out of the box and you can just worry about writing you tests and code.