# Nifty Triangle Test Example

The triangle test is considered by many a “classic” example of a software test challenge. In fact, I believe it goes all the way back to Glenford Meyer’s The Art of Software Testing – the first book ever published on software testing – and may go back as far as the testing chapter of Jerry Weinberg’s book on PL/1 programming.

The problem is simple – you have three inputs for sides of a triangle, and the computer will tell you if the values you entered are scalene, isosceles, equilateral, or not a triangle.

So why am I ambivalent? Because it’s a geometry problem with big words in it – and some people are simply not confident or comfortable talking about math. So you could have a very good tester who doesn’t “grok” the problem, or you could have a very astute potential tester who is turned off by the exercise.

However, if you /like/ math and geometry, and you can handle it, then have I got a website for you – triangle test (which I got from Elisabeth Hendrickson via twitter) not only simulates the problem, but evaluates the answers you give as you run your test cases. It tracks the kinds of tests you run, and, when you think you are done, can ‘evaluate’ the scenarios you ran and give you some suggestions you may have missed.

Now, it’s a canned exercise, don’t take it too seriously. But for a little quick feedback fun challenge, it’s hard to beat. Check it out.

Of course, the kind of tests the simulator allows you to run are constrained by the input; they are traditional send-it-different-input kinds of tests. That’s a very developer-ish way of looking at testing, which ties back to what happens when you have an SDET worldview. More on that tomorrow.

## 4 comments on “Nifty Triangle Test Example”

1. Lisa says:

Your post prompted this math-o-phobe to try the exercise, and actually I did pretty well! Funny how the perception of “math” and “geometry” turned me off of what is actually not a bad way to see what test cases someone comes up with.

2. hwtsam.com says:

I like the exercise – yes, it’s limited, and yes, it’s not a “real” application, but conceptually, it’s quite good. It tells you when you’re overtesting (something easy to do in exploratory testing), and it give you a variety of other valid feedback on your choices of inputs.

Looking forward to your post tomorrow.

3. Joris says:

Matt,

It goes back at least to Fred Gruenberger. In his paper Program Testing: the Historical Perspective he mentions the triangle problem. The paper is based on a talk held during the Chapel Hill Symposium (1972) and is published in the book Program Test Methods (1973), edited by William Hetzel.

In the paper Gruenberger mentions the book Computers and Society by Richard Hamming (1972) as a source for the triangle problem.

4. Reno says:

Hey, Matt, this triangle test is published in the book “How We Testing Software in Microsoft” too.