Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li><p>With test driven design, you normally want to write the tests first. They should cover the operations you're actually using/going to use. I.e. unless they're necessary for the client code to do its job, they shouldn't exist. Selecting test cases is something of an art. There are obvious things like testing boundary conditions, but in the end, nobody's found a really reliable, systematic way of assuring that tests (unit or otherwise) cover all the conditions that matter.</p></li> <li><p>Yes, there are frameworks. A couple of the best known are:<br> <a href="http://www.boost.org/doc/libs/1_53_0/libs/test/doc/html/utf.html" rel="nofollow noreferrer">Boost Unit Test Framework</a><br> <a href="http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page" rel="nofollow noreferrer">CPPUNit</a><P> CPPUnit is a port of JUnit, so those who've used JUnit previously will probably find it comfortable. Otherwise, I'd tend to recommend Boost -- they also have a <a href="http://www.boost.org/doc/libs/1_53_0/libs/test/doc/html/utf/testing-tools.html" rel="nofollow noreferrer">Test Library</a> to help write the individual tests -- rather a handy addition.</p></li> <li><p>Unit tests should be sufficient to ensure that the code works. If (for example) you have a private function that's used internally, you generally don't need to test it directly. Instead, you test whatever provides the public interface. As long as that works correctly, it's no business of the outside world how it does its job. Of course, in some cases it's <em>easier</em> to test little pieces, and when it is, that's perfectly legitimate -- but ultimately you care about the visible interface, not the internals. Certainly the whole external interface should be exercised, and test cases generally chosen to exercise the paths through the code. Again, there's nothing massively different about unit tests versus other kinds. It's mostly just a more systematic way of applying normal testing techniques.</p></li> </ol>
 

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