How To Test Mathematical Functions?

Your task is to test mathematical function that is part of your program under test. It is time to use the mathematical model oracle. The post is aligned with the Black Box Software Testing Foundations course (BBST) designed by Rebecca Fiedler, Cem Kaner, and James Bach.

When you need to test mathematical functions, to be effective, you will use automation through mathematical tools. The most famous mathematical tool is abacus[ source], but these days it can not help you because of abacus limited counting support. You can not calculate large numbers with an abacus.

Then you can use a modern calculator. Checking the results of your system under test and calculator results could not be automated. Doing it manually by reading the calculator screen and your system under test output is error-prone.

Testing mathematical functions are best done using programming. You can test large numbers very fast.

Mathematical functions have one exciting property, inversion. If the function has the inverse function pair, that means that when we put the output of the first function as input to the inverse function, we get the original input data of the first function. Initial input could differ, depending on the function calculation precision. Square and the square root are one example.

You can use the inverse function of your system under test, or you can use the inverse function of comparable products.

Another way of testing the mathematical function is to compare its result with a comparable product that implements the same mathematical function.

It could be 100% automated, for not “exotic” mathematical functions, you have at your disposal a lot of comparable products.

If the function does not have an inverse counterpart, you can not use an inverted trick for the oracle. Also, if the function is complicated, like AI algorithm implementation, it is tough to get verification points (oracles) for those calculations.

Originally published at https://blog.tentamen.eu on October 14, 2019.

Written by

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store