<p>Let's say we have a simple function defined in a pseudo language.</p>

<pre><code>List&lt;Numbers&gt; SortNumbers(List&lt;Numbers&gt; unsorted, bool ascending);
</code></pre>

<p>We pass in an unsorted list of numbers and a boolean specifying ascending or descending sort order. In return, we get a sorted list of numbers.</p>

<p>In my experience, some people are better at capturing boundary conditions than others. The question is, "How do you know when you are 'done' capturing test cases"?</p>

<p>We can start listing cases now and some clever person will undoubtedly think of 'one more' case that isn't covered by any of the previous.</p>

[{'answer_id': 12571, 'author': 'Justin Standard', 'author_id': 92, 'author_profile': 'https://Stackoverflow.com/users/92', 'pm_score': 4, 'selected': True, 'text': "<p>Don't waste too much time trying to think of <em>every</em> boundry condition.  Your tests won't be able to catch <em>every</em> bug first time around.  The idea is to have tests that are <em>pretty good</em>, and then each time a bug <em>does</em> surface, write a new test specifically for that bug so that you never hear from it again.</p>\n\n<p>Another note I want to make about code coverage tools.  In a language like C# or Java where your have many get/set and similar methods, you should <strong>not</strong> be shooting for 100% coverage.  That means you are wasting too much time writing tests for trivial code.  You <em>only</em> want 100% coverage on your complex business logic.  If your full codebase is closer to 70-80% coverage, you are doing a good job.  If your code coverage tool allows multiple coverage metrics, the best one is 'block coverage' which measures coverage of 'basic blocks'.  Other types are class and method coverage (which don't give you as much information) and line coverage (which is too fine grain).</p>\n"}, {'answer_id': 12573, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 0, 'selected': False, 'text': '<p>A good code coverage tool really helps.</p>\n\n<p>100% coverage doesn\'t mean that it definitely is adequately tested, but it\'s a good indicator.</p>\n\n<p>For .Net NCover\'s quite good, but is no longer open source.</p>\n\n<hr>\n\n<p>@Mike Stone - \nYeah, perhaps that should have been "high coverage" - we aim for 80% minimum, past about 95% it\'s usually diminishing returns, especially if you have belt \'n\' braces code.</p>\n'}, {'answer_id': 12583, 'author': 'Mike Stone', 'author_id': 122, 'author_profile': 'https://Stackoverflow.com/users/122', 'pm_score': 0, 'selected': False, 'text': '<p>@Keith</p>\n\n<p>I think you nailed it, code coverage is important to look at if you want to see how "done" you are, but I think 100% is a bit unrealistic a goal.  Striving for 75-90% will give you pretty good coverage without going overboard... don\'t test for the pure sake of hitting 100%, because at that point you are just wasting your time.</p>\n'}, {'answer_id': 13064, 'author': 'Christian Lescuyer', 'author_id': 341, 'author_profile': 'https://Stackoverflow.com/users/341', 'pm_score': 3, 'selected': False, 'text': '<blockquote>\n<p>How do you know when you are \'done\' capturing test cases?</p>\n</blockquote>\n<p>You don\'t.You can\'t get to 100% except for the most trivial cases. Also 100% coverage (of lines, paths, conditions...) doesn\'t tell you you\'ve hit all boundary conditions.</p>\n<p>Most importantly, the test cases are not write-and-forget. <strong>Each time you find a bug, write an additional test.</strong> Check it fails with the original program, check it passes with the corrected program and add it to your test set.</p>\n<p>An excerpt from <a href="https://rads.stackoverflow.com/amzn/click/com/0471469122" rel="nofollow noreferrer" rel="nofollow noreferrer"><em>The Art of Software Testing</em></a> by Glenford J. Myers:</p>\n<ol>\n<li>If an input condition specifies a range of values, write test cases for the ends of the range, and invalid-input test cases for situations just beyond the ends.</li>\n<li>If an input condition specifies a number of values, write test cases for the minimum and maximum number of values and one beneath and beyond these values.</li>\n<li>Use guideline 1 for each output condition.</li>\n<li>Use guideline 2 for each output condition.</li>\n<li>If the input or output of a program is an ordered set focus attention on the first and last elements of the set.</li>\n<li>In addition, use your ingenuity to search for other boundary conditions</li>\n</ol>\n<p>(<em>I\'ve only pasted the bare minimum for copyright reasons.</em>)</p>\n<p>Points 3. and 4. above are very important. People tend to forget boundary conditions for the outputs. 5. is OK. 6. really doesn\'t help :-)</p>\n<h2>Short exam</h2>\n<p>This is more difficult than it looks. Myers offers this test:</p>\n<blockquote>\n<p>The program reads three integer values from an input dialog. The three values represent the lengths of the sides of a triangle. The program displays a message that states whether the triangle is scalene, isosceles, or equilateral.</p>\n<p>Remember that a scalene triangle is one where no two sides are equal, whereas an isosceles triangle has two equal sides, and an equilateral triangle has three sides of equal length. Moreover, the angles opposite the equal sides in an isosceles triangle also are equal (it also follows that the sides opposite equal angles in a triangle are equal), and all angles in an equilateral triangle are equal.</p>\n</blockquote>\n<p>Write your test cases. How many do you have? Myers asks 14 questions about your test set and reports that highly qualified professional programmes average 7.8 out of a possible 14.</p>\n'}, {'answer_id': 137296, 'author': 's_t_e_v_e', 'author_id': 21176, 'author_profile': 'https://Stackoverflow.com/users/21176', 'pm_score': 1, 'selected': False, 'text': "<p>From a practical standpoint, I create a list of tests that I believe must pass prior to acceptance.  I test these and automate where possible.  Based on how much time I've estimated for the task or how much time I've been given, I extend my test coverage to include items that should pass prior to acceptance.  Of course, the line between must and should is subjective.  After that, I update automated tests as bugs are discovered.</p>\n"}]
['https://Stackoverflow.com/questions/12569', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12081/']