{"id":17945,"date":"2018-01-10T12:12:17","date_gmt":"2018-01-10T20:12:17","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=17945"},"modified":"2019-02-18T17:48:06","modified_gmt":"2019-02-18T17:48:06","slug":"boost-test-unit-testing-dynamic-library-support-and-new-item-template","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/boost-test-unit-testing-dynamic-library-support-and-new-item-template\/","title":{"rendered":"Boost.Test Unit Testing: Dynamic Library support and New Item Template"},"content":{"rendered":"<p><a href=\"https:\/\/blogs.msdn.microsoft.com\/c\/2018\/01\/12\/boost-test\u5355\u5143\u6d4b\u8bd5\uff1a\u52a8\u6001\u5e93\u652f\u6301\u548c\u65b0\u9879\u76ee\u6a21\u677f\/\">\u70b9\u8fd9\u91cc\u770b\u4e2d\u6587\u7248<\/a> <\/p>\n<p><em>If you\u2019re just getting started and want to learn more about C++ Unit Testing, check out our <\/em><a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/test\/writing-unit-tests-for-c-cpp\"><em>guide<\/em><\/a>.<\/p>\n<p>We are excited to announce that, in addition to Boost.Test static library support, <strong><a href=\"https:\/\/www.visualstudio.com\/vs\/preview\/\">Visual Studio 2017 15.6 Preview 2<\/a> now offers Boost.Test dynamic library support and a Boost.Test item template<\/strong>. This means it is now easier than ever to incorporate Boost.Test unit tests into your Visual Studio projects.<\/p>\n<h3>Boost.Test Dynamic Library<\/h3>\n<p>If you are already using the Boost.Test dynamic library, your unit tests will be supported immediately.\u00a0If you don\u2019t already have Boost.Test on your machine, the simplest method for acquiring the Boost.Test\u00a0dynamic library is via\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows\/\">vcpkg<\/a>.<\/p>\n<p>Using vcpkg, simply run the following commands to install Boost.Test and then make it available to all your VS projects. We only need to install the Boost.Test portion of Boost, but if you would like to acquire the entirety of Boost, just replace \u201cboost-test\u201d with \u201cboost\u201d.<\/p>\n<pre class=\"prettyprint disable-colors\"> vcpkg install boost-test\nvcpkg integrate install <\/pre>\n<p>That\u2019s it. You can now seamlessly write, discover, and run unit tests using the Boost.Test framework in Visual Studio. If you don\u2019t prefer the dynamic library, please reference this <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/test\/how-to-use-boost-test-for-cpp\">guide to using the Boost static library<\/a>.<\/p>\n<h3>Boost.Test Item Template<\/h3>\n<p>Once you have Boost.Test integrated with Visual Studio, we\u2019ve added an item template so you can quickly add unit tests to your project. To do so, Right-click the project and then select <em><strong>Add &gt; New Item\u2026 &gt; Visual C++ &gt; Test &gt; Boost.Test<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/boostItemTemplate.png\"><img decoding=\"async\" width=\"879\" height=\"498\" class=\"alignnone size-large wp-image-17965\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/boostItemTemplate-1024x580.png\" \/><\/a><\/p>\n<p><span style=\"font-family: Calibri\"><span style=\"color: #000000\">This automatically creates a <em>.cpp<\/em> file with some placeholder tests that will be automatically colored. After building your project, you can manage your tests in the Test Explorer window. The item template uses the single-header variant of Boost.Test, but you can modify the path to use the standalone library variant. Feel free to learn more about the <\/span><a href=\"http:\/\/www.boost.org\/doc\/libs\/1_66_0\/libs\/test\/doc\/html\/boost_test\/usage_variants.html#boost_test.usage_variants.single_header\">variants of Boost.Test<\/a><\/span><span style=\"color: #000000;font-family: Calibri\">.<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/boostTest.png\"><img decoding=\"async\" width=\"879\" height=\"248\" class=\"alignnone size-large wp-image-17966\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/boostTest-1024x289.png\" \/><\/a><\/p>\n<h3>Talk to Us<\/h3>\n<p><span style=\"font-family: Calibri\"><span style=\"color: #000000\"><span style=\"font-family: Calibri Light\"><\/span><span style=\"font-size: x-large\"><\/span><span style=\"color: #000015\"><\/span>We are always working to give you the best development experiences possible. Let us know what you would like to see next. If you come across any issues, please file them on the <\/span><a href=\"https:\/\/github.com\/Microsoft\/vs-boost-unit-test-adapter\">Test Adapter for Boost.Test GitHub<\/a><\/span><span style=\"color: #000000;font-family: Calibri\">. <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u70b9\u8fd9\u91cc\u770b\u4e2d\u6587\u7248 If you\u2019re just getting started and want to learn more about C++ Unit Testing, check out our guide. We are excited to announce that, in addition to Boost.Test static library support, Visual Studio 2017 15.6 Preview 2 now offers Boost.Test dynamic library support and a Boost.Test item template. This means it is now easier [&hellip;]<\/p>\n","protected":false},"author":329,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-17945","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>\u70b9\u8fd9\u91cc\u770b\u4e2d\u6587\u7248 If you\u2019re just getting started and want to learn more about C++ Unit Testing, check out our guide. We are excited to announce that, in addition to Boost.Test static library support, Visual Studio 2017 15.6 Preview 2 now offers Boost.Test dynamic library support and a Boost.Test item template. This means it is now easier [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/17945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/329"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=17945"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/17945\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=17945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=17945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=17945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}