Advertisement

Errors, Exceptions and Testing

  • Joe Pitt-Francis
  • Jonathan Whiteley
Chapter
Part of the Undergraduate Topics in Computer Science book series (UTICS)

Abstract

Until this point we have used assert statements to ensure that a condition required by the code to generate correct output is met. For example, we might check that a number that we were going to take the square root of is non-negative, and trip an assertion if this condition were not met. Whilst this approach is very useful as it pinpoints errors, it is rather inflexible as it terminates the code at the instant that an assertion is tripped. We would much rather the code instead made some attempt to fix the problem itself, if that were possible, warned us of the possible effects of the fix if necessary, and then carried on executing. This is possible through the use of exceptions, which is one focus of this chapter. The second focus of this chapter is the use of suitable testing techniques to allow software to be developed in a sustainable manner.

Copyright information

© Springer International Publishing AG, part of Springer Nature 2017

Authors and Affiliations

  1. 1.University of OxfordOxfordUK

Personalised recommendations