Testing your code: the basics

Testing a code… a very vast subject. For some it is a fuzzy concept, borderline boring, for others it is the heart of programming; but everyone agrees that testing a code correctly is not an easy task.

In most languages, there are libraries to facilitate the writing of tests, still it remains up to you to make the tests relevant and effective to understand the limits and the flaws of our implementation and design. And then there is the age-old question: have I tested my code enough?

It might not be an existential question if you’re writing a little library for yourself only (though…), but very quickly the question becomes legit. Keep in mind that most of big software projects used to start as small projects that have grown unexpectedly. Here is how the creator of Linux described the first public version of the now-ubiquitous operating system:

I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) for 386(486) AT clones.

In this practical, we will cover two common tools to automate the execution of tests. As these tools are language-specific you will need to pick which language you want to study here: