From: "Robert C. Martin" Date: 2001-12-11T23:23:05+09:00 Subject: [ruby-talk:28221] Re: John Roth dolt ( Re: A challenge to proponents of Unit Testing. ) On 11 Dec 2001 02:39:53 -0800, sureshvv@hotmail.com (suresh vv) wrote: >Robert C. Martin wrote in message news:... >> >> >Set sides; // data structure allows no duplicates. >> >> >sides.add(a); >> >> >sides.add(b); >> >> >sides.add(c); >> >> >return sides.length(); // 1 = equilateral, 2=isoceles, 3=scalene. >> ^^^^^^^^^--oops. >> >> > >> >> >What am I missing? >> > >> >> The intent was to return a 1 for equilateral, 2 for isoceles, and 3 >> for scalene. Representing the triangle was not part of the job. >> > >Sounds like a cop out. You forgot/ignored the "triangle" part of the problem >and just dealt with 3 numbers, returning the number of unique numbers. > >There is a lesson in there somwhere for what happens when you >get away from the "real world". A cop out? Why is a simplification a cop out? Someone had asserted that it took 20+ test cases to verify a function that evaluated a triangle. I proposed an algorithm that would likely require less than 22 tests. Kent used that algorithm to propose five tests. Someone else pointed out that certain illegal triangles pass the tests, so one more test case is needed. The whole point here is to show that white box unit test coverage is strongly dependent upon the design of the system. If you know the design, then you can significantly prune the tests without losing coverage. Robert C. Martin | "Uncle Bob" | Software Consultants Object Mentor Inc. | rmartin@objectmentor.com | We'll help you get PO Box 5757 | Tel: (800) 338-6716 | your projects done. 565 Lakeview Pkwy | Fax: (847) 573-1658 | www.objectmentor.com Suite 135 | | www.XProgramming.com Vernon Hills, IL, | Training and Mentoring | www.junit.org 60061 | OO, XP, Java, C++, Python| "One of the great commandments of science is: 'Mistrust arguments from authority.'" -- Carl Sagan