Errors

Errors#

This chapter focuses on a number of different topics to help you identify and fix errors, which are an essential component of software testing. Incorporating the concepts in this chapter into your own coding practice will help you fix problems in the future, especially as you work on larger projects with multiple people.

Why should we learn about software testing?

Testing our code is necessary, because we as humans all make mistakes. Some of our mistakes may not be that important, but some can be dangeours and harmful. There are numerous examples of the latter such as the explosion of the Ariane 5 rocket or the problem with NASA’s Mars Climate Orbiter. You can read more on these examples here. Testing our code for hidden flaws is the first step towards ensuring that the programs we write are robust.

https://static.wixstatic.com/media/cfc1ef_55f398d6fbdb418ea4970567251efe6a.png/v1/fill/w_680,h_476,al_c,q_95/cfc1ef_55f398d6fbdb418ea4970567251efe6a.webp

Fig. 1 A depiction of the NASA’s Mars Climate Orbiter disaster. The incongruence in the units used by scientists at NASA (metric unit) and Lockheed Martin (US customary units) led the space probe too close to the planet. It was either destroyed in the atmosphere or escaped the planet’s vicinity and entered an orbit around the Sun. (Source: Unleesh.com)#

What is debugging?

Debugging is the process of identifying code-related problems (bugs) by analysing the behaviour of the program we have written. Testing and debugging are complementary to one another. Testing is used to identify a bug, while debugging is used to fix a bug.

In the sections that follow, we will start to learn about errors as a practical way of identifying issues with our code. Then we will learn how to improve our code with testing to make it easier to debug in the future.