Improve Your Testing #6: The One Algorithm To Test Them All

Learn how to use Arrange-Act-Assert to improve your ability and quality of testing

David Rodenas PhD

--

«The three stages of the algorithm» — Prompted by the author.

Have you noticed that in software development there’s an algorithm for everything? Sorting data? There are algorithms for sorting. Finding the shortest path? There’s another algorithm. And so on. But when it comes to implementing software tests, if your code does what it’s supposed to do, there is one algorithm to rule them all.

Fascinating, isn’t it? Normally, we tend to overcomplicate testing, but there is one single algorithm that makes it simple: the AAA. It leaves out all the noise and focuses on what really matters. And you don’t even need to be a great developer to follow it; it’s within everyone’s reach.

The one algorithm to test them all

We might find it surprising that there’s only one algorithm, which is nothing more than a way to structure test code, but it’s not. It creates a structure that brings simplicity to this chaotic world of testing. And even more, there’s no other more efficient way. And it comes out of necessity. Because testing must be simple, simple enough not to need a test for the test. And this AAA gives us this simplicity along with the effectiveness we need.

--

--

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.