<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GoogleTest on Cheat Sheet</title><link>/tags/googletest/</link><description>Recent content in GoogleTest on Cheat Sheet</description><generator>Hugo</generator><language>en</language><atom:link href="/tags/googletest/index.xml" rel="self" type="application/rss+xml"/><item><title>Unit Testing</title><link>/programming/cpp/advanced/unit-testing/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/programming/cpp/advanced/unit-testing/</guid><description>&lt;h1 id="unit-testing"&gt;Unit Testing&lt;a class="anchor" href="#unit-testing"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Practical guidelines for C++ unit testing with open-source &lt;a href="https://github.com/google/googletest"&gt;GoogleTest (&lt;code&gt;google/googletest&lt;/code&gt;)&lt;/a&gt; and &lt;strong&gt;Abseil (&lt;code&gt;abseil-cpp&lt;/code&gt;)&lt;/strong&gt;, covering test file namespace layout, how &lt;code&gt;TEST&lt;/code&gt; and &lt;code&gt;TEST_F&lt;/code&gt; expand under the hood, &lt;code&gt;Test Fixture&lt;/code&gt; lifecycles, and choosing between &lt;code&gt;CHECK&lt;/code&gt;, &lt;code&gt;ASSERT_*&lt;/code&gt;, and &lt;code&gt;EXPECT_*&lt;/code&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-namespace-structure-in-test-files"&gt;1. Namespace Structure in Test Files&lt;a class="anchor" href="#1-namespace-structure-in-test-files"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id="1-idiomatic-layout-namespace-pkg--namespace----"&gt;1. Idiomatic Layout: &lt;code&gt;namespace &amp;lt;pkg&amp;gt; { namespace { ... } }&lt;/code&gt;&lt;a class="anchor" href="#1-idiomatic-layout-namespace-pkg--namespace----"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When &lt;code&gt;greeter.h&lt;/code&gt; and &lt;code&gt;greeter.cc&lt;/code&gt; declare symbols inside &lt;code&gt;namespace greeter&lt;/code&gt;, the corresponding &lt;code&gt;greeter_test.cc&lt;/code&gt; should open the &lt;strong&gt;same outer &lt;code&gt;namespace greeter&lt;/code&gt;&lt;/strong&gt; and wrap the test definitions inside an inner &lt;strong&gt;&lt;a href="../../programming/cpp/primer/namespaces/"&gt;anonymous namespace&lt;/a&gt; (&lt;code&gt;namespace { ... }&lt;/code&gt;)&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>