<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Boost.test on The Lone C++ Coder's Blog</title><link>https://www.lonecpluspluscoder.com/tags/boost.test/</link><description>Recent content in Boost.test on The Lone C++ Coder's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Sat, 27 Sep 2014 16:13:22 +0000</lastBuildDate><atom:link href="https://www.lonecpluspluscoder.com/tags/boost.test/index.xml" rel="self" type="application/rss+xml"/><item><title>Some Boost.Test notes</title><link>https://www.lonecpluspluscoder.com/2014/09/27/some-boost-test-notes/</link><pubDate>Sat, 27 Sep 2014 16:13:22 +0000</pubDate><author>Timo Geusch</author><guid>https://www.lonecpluspluscoder.com/2014/09/27/some-boost-test-notes/</guid><description>&lt;p&gt;These are just a couple of notes for some neat tips and tricks I&amp;rsquo;ve discovered over the years when using &lt;a href="http://www.boost.org/doc/libs/1_56_0/libs/test/doc/html/index.html"&gt;Boost.Test&lt;/a&gt;. They may not be all that useful to everybody else but they&amp;rsquo;re the ones I tend to forget about and then end up rediscovering. I&amp;rsquo;m using most of these with recent versions of Boost and these were tested with 1.54.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can nest test suites. I don&amp;rsquo;t use this feature and was surprised to discover it, but it makes a lot of sense if you&amp;rsquo;re dealing with large test suites that can be easily broken down into smaller logical chunks.&lt;/li&gt;
&lt;li&gt;If you arrange the tests in test suites (which you should anyway), you can run a single test suite by using &lt;code&gt;-run_test=TestSuite&lt;/code&gt;. You can also run a single test inside a test suit or a nested suit by giving the appropriate path to -run_test, like so &lt;code&gt;-run_test=TestSuite/TestName&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Fixtures are normal C++ structs/classes so you can derive from them to create more specialized fixtures. For example, in a set of test suite used to test a fairly large set of COM APIs, I use a single fixture to initialize COM, then derive fixtures to set up the tests for each interface. This cuts down a lot on duplicated initialization code.&lt;/li&gt;
&lt;li&gt;Boost.Test supports fixtures. Make lots of use of them to set up the environment for each of your tests instead of dumping a lot of the initialization code into each test case, which makes the test cases smaller, easier to read and you can follow the &amp;ldquo;let the first call in your test be the function you&amp;rsquo;re testing&amp;rdquo; mantra.&lt;/li&gt;
&lt;li&gt;Members of the fixtures can be used directly in your unit tests&lt;/li&gt;
&lt;li&gt;You can use BOOST_CHECK/BOOST_REQUIRE macros in the fixtures as well, although I would advise to make fairly minimal use of that. It does help if you are trying to test what I call &amp;ldquo;flaky&amp;rdquo; pieces of code.&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>