If you’re 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 than ever to incorporate Boost.Test unit tests into your Visual Studio projects.
Boost.Test Dynamic Library
If you are already using the Boost.Test dynamic library, your unit tests will be supported immediately. If you don’t already have Boost.Test on your machine, the simplest method for acquiring the Boost.Test dynamic library is via vcpkg.
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 “boost-test” with “boost”.
vcpkg install boost-test vcpkg integrate install
That’s it. You can now seamlessly write, discover, and run unit tests using the Boost.Test framework in Visual Studio. If you don’t prefer the dynamic library, please reference this guide to using the Boost static library.
Boost.Test Item Template
Once you have Boost.Test integrated with Visual Studio, we’ve added an item template so you can quickly add unit tests to your project. To do so, Right-click the project and then select Add > New Item… > Visual C++ > Test > Boost.Test
This automatically creates a .cpp 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 variants of Boost.Test.
Talk to Us
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 Test Adapter for Boost.Test GitHub.