Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Do yourself a favor and go straight to <a href="http://code.google.com/p/googletest/" rel="noreferrer">Google Test</a>, which makes CppUnit and <code>boost::unit_test</code> look clunky and repetitive.</p> <p>For example, say you have a simple fixture:</p> <pre><code>class MyFixture : public ::testing::Test { protected: int foo; virtual void SetUp() { foo = 0; } }; </code></pre> <p>To add a test to your fixture, write it!</p> <pre><code>TEST_F(MyFixture, FooStartsAtZero) { EXPECT_EQ(0, foo); } </code></pre> <p>That's all you need. Notice the lack of explicit testsuite declarations or a separate agenda that repeats all your tests' names.</p> <p>Compile it as in</p> <pre>$ g++ -o utest utest.cpp -lgtest -lgtest_main</pre> <p>and run your test to get</p> <pre>Running main() from gtest_main.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from MyFixture [ RUN ] MyFixture.FooStartsAtZero [ OK ] MyFixture.FooStartsAtZero (0 ms) [----------] 1 test from MyFixture (0 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (0 ms total) [ PASSED ] 1 test.</pre> <p>(Run it yourself to see the nice green text for passing tests!)</p> <p>This is only the beginning. Take a look at the <a href="https://code.google.com/p/googletest/wiki/Primer" rel="noreferrer">Google Test primer</a> and the <a href="https://code.google.com/p/googletest/wiki/AdvancedGuide" rel="noreferrer">advanced guide</a> to see what else is possible.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload