Home > The Unit Test Framework > Compilation > Direct include
PrevNext

Including the UTF directly into your test module

If you prefer to avoid the standalone library compilation you can either include all files that constitute the static library in your test module's makefile or include them as a part of a test module's source file. To facilitate the later variant the UTF presents the single-header usage variant. In either case no special build options or macro definitions are required to be added to your compilation options list by default. But the same flags that can be used for the standalone library compilation are applicable in this case. Though, obviously, neither BOOST_TEST_DYN_LINK nor BOOST_TEST_NO_LIB are applicable. This solution may not be the best choice in a long run, since it requires the UTF sources recompilation for every test module you use it with and for every change of a test module you are working on. In a result your testing cycle time may increase. If it become tiresome, I recommend switching to one of the prebuilt library usage variants.
如果你不想要使用獨立的庫,你可以選擇將組成靜態庫的所有文件包含進你的測試模塊的 makefile 中,或者將它們作為測試模塊的一部分源文件。 UTF 為了實現後一種版本,提供了單個頭文件使用變種 (single-header usage variant)。 在這種情況下,沒有額外的生成選項或宏定義需要被加入到你的默認編譯選項中。 但在 standalone library compilation 中使用的標籤同樣可以應用在這種情況。 當然,很明顯 BOOST_TEST_DYN_LINKBOOST_TEST_NO_LIB 是不應該使用的。 這個解決方案可能不是長期運行的最佳選擇,因為一旦你的測試模塊發生變化,UTF 源文件都需要被重新編譯,這將導致你的測試週期變長。 如果這變得令人厭煩,我建議你選擇預編譯的庫使用。


PrevUpHomeNext