The Triangle Problem is a ‘classic’ from Software Testing, described in many books and training courses. This post describes the problem, links to some applications you can use to practice on and describes some nuances around the testing.
What is The Triangle Problem?
The application context surrounding the Triangle Problem is usually:
Given an application which takes three inputs, each representing the length of one side of a triangle, the application will respond with a message identifying if the inputs are: invalid, or represent a triangle, if they represent a triangle then the application will respond with the type of triangle (equilateral, isosceles, scalene).
The ‘problem’ is usually presented as a test design problem:
- How would you test this?
- What inputs would you use to test this?
Implementations of the Triangle Application
During my research I found an implementation by MathWarehouse.com the Triangle Calculator below:
Triangle Problem Exercises
- In advance of testing, create a set of inputs with expected results, try them in the application, review coverage
- Work with others, repeat exercise above, compare inputs and coverage
- Create a ‘minimum’ input set for your testing.
Using either of the implementations:
- The input design ignores the GUI implementation, what else do you need to do to test the GUI?
- Test the drawing functionality, does that require different test input?
- Can you spot any hidden functionality? If so, test it.
- When would creating a ‘minimum’ input set be helpful?
Tool Support working with Test Pages Implementation:
- Are there any lightweight adhoc tools or approaches for automating that could help you as you perform exploratory testing?
Automating Test Pages implementation:
- Review the implementation from the perspective of “Is this automatable?”
- How many different ways could you automate this?
- Would any changes to the implementation make automating easier?
- Try automating the implementation.
- Review the code for the Test Pages Implementation, does that help or hinder your testing?
Using the Test Pages implementations:
- Automate the Unit Testing from the console.
Make up your own exercises to push your approach to testing this simple example as far as you can.
Books and Research Resources
The Triangle Problem is described and referenced in the resources and books that follow.
- The Art of Software Testing - Glenford Myers
- Software Testing a Craftsman’s Approach - Paul C. Jorgensen
- Testing Object-oriented Systems - Robert Binder
- Test Driven Development By Example - Kent Beck
- Exercise: Analyzing the Triangle Problem by Ross Collard from the Third Annual Workshop on the Teaching of Software Testing 2004
- testingeducation.org used to have easy to find links to this material and details of teh conference but the site seems to have invalidated the content.
- there are various sites which have archived this pdf
Expanded content on The Triangle Problem was released to Patreon Supporters back in 2022