- Which came first, the chicken or the egg? And after all, why would any of them cross the road?
That question is as old as time.
- How would you test a program which can return the type of a triangle based on the side widths?
That question is as old as me.
In 1979 (yes, I am that young 😉), Glenford J. Myers wrote what was to be the first classic book on Software Testing.
Called “The Art of Software Testing“, this book is very old, and written with old software in mind – most technologies and methodologies existing today were not dreamed of back then.
Well, it turns out the principles of software – from writing it to testing it – are still pretty much the same. Software is still written on sort of punchcards, the punchcards just got more complex and flexible… The book content is surprisingly relevant for today’s testers – so much, that it was updated only once in almost 30 years.
If you haven’t, read the book. Unfortunately, I have read it only partially meanwhile.
Maybe the most known contribution of Mr. Glenford in this book is the testing self-assessment challenge in the introduction.
It goes like this:
A Software is given, which receives three inputs (numbers) that define the size of a triangle’s sides. The SW can, then, categorize the triangle in one of these categories: Equilateral, Scalene, Isosceles or Invalid.
How many test cases can you build for testing this triangle?
The more heterogeneous the cases the better, and: The more effective, better yet.
Myers brings then an assessment criteria. If the test cases you came up fit into enough categories such as the ones below, you are in a good way:
- Test cases that represents a valid scalene/isosceles/equilateral triangle.
- Test cases that represent valid isosceles triangles such that there are all three permutations of two equal sides.
- Test cases in which one side has a zero value, or negative value.
- Test cases that represent invalid triangles.
The example is famous, because it grasps clearly the distance between coding and testing. Writing such a program may take about 30 minutes of work to a programmer (I did this first version in 20 minutes), but testing the program can be a never-ending task.
How would we use Triangle Problem?
We will use this problem as the example to do all the acceptance tests from FitNesse.
We’ll have this DLL – based on the C# code above – and we will connect this to our FitNesse server. We will then start checking inputs and outputs. All this in Part 2 of the FitNesse Series!
The triangle exercise is now all over the internet.
You can read about it in the following links:
- Google Search – “software testing triangle equilateral”
You’ll find most of what’s online and cool here.
- Example with working application (!) for you to test:
Quality Tree Software’s Elisabeth brought the triangle to the attention of all again when she posted it on her website.
The working example by Elisabeth: http://www.testobsessed.com/exercises/triangle.html
- Challenge Definition by Alex Samurin
Alex has a short explanation of the original problem as it was presented by Myers.
- Malik’s Code Inspections
Malik summarizes in two paragraphs the two most interesting points on the abovementioned application by Elisabeth: Floating point calculations and sorting algorithms.
- The exercise, Bollywood style
- Last but not least ;):
My post on it: A Triangle mystery (not the Bermudas’). I turned this post into a page/article, ’cause it is a useful subject.
Pay attention, I am not trying to really test the triangle application. This is new stuff – we are using the triangles to test the FitNesse framework! Go for it!