About Triangle App

Enter the lengths of the three sides of a triangle. The program will inform you if the triangle is equilateral, isosceles or scalene.

About This Triangle Application

There are three text input fields, each representing a side of a triangle.

Press the button Identify Triangle Type to trigger the JavaScript functionality that reads the input fields and runs an algorithm to determine the type of triangle.

Any field or algorithm errors will be displayed on the page.

When the application believes you have entered a triangle it will also draw a representation of the triangle in the on page canvas element.

Triangle Algorithm

Dev Tools

Use the Dev Tools and check that the description is correct, does the page actually send the form to the server? You should be able to see the form submission in the Network Tab.

Getting into the habit of using the Dev Tools when testing will help you understand the applications that you work with very quickly.

Automated Execution

For automating, it is a simple form with a button.

Since the application uses JavaScript you may need to write synchronization code.

Detecting the validation errors and on screen error messages should be easy to find and assert on.

The canvas will be harder to automate.

Exploratory Testing

The Triangle App is a classic Testing Case Study so you'll find plenty of ideas and documented approaches online.

JavaScript Hacking

The JavaScript is visible in the page and hooked on to the DOM so it is possible to automate the application and test the functionality from the console or using JavaScript Executor.

Multiple Versions

There are actually two slightly different implementations of the triangle app.

They might have different issues.


What is The Triangle Problem?

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.

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:

Triangle Problem Exercises

Traditional:

Using either of the implementations:

Discuss:

Tool Support working with Test Pages Implementation:

Automating Test Pages implementation:

Code Review:

Using the Test Pages implementations:

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.

Books:

Additional Resources:

Other Implementations of the Triangle Application

During my research I found an implementation by MathWarehouse.com the Triangle Calculator below:

Help keep this site free by joining our Patreon Membership site. Membership costs as little as $1 a month and includes access to exclusive e-books and online training courses.