Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Runtime tests are tests that run as part of the program itself. They may take the form of checks within the code, as shown below:

population = population + people_born - people_died

// test that the population is positive
if (population < 0):
  error( 'The number of people can never be negative' )

Another example of a use of runtime tests is internal checks within functions that verify that their inputs and outputs are valid, as shown below:

function add_arrays( array1, array2 ):

// test that the arrays have the same size
if (array1.size() != array2.size()):
  error( 'The arrays have different sizes!' )

output = array1 + array2

if (output.size() != array1.size()):
  error( 'The output array has the wrong size!'' )

return output

Advantages of runtime testing:

Disadvantages of runtime testing: