Study Atlas › Computer Science › Software engineering

Testing and debugging

Systematically checking that software behaves as intended and finding the cause of defects.

Edited by Alex C, EduAlx · Sources cited below

Explanation

Levels: unit, integration, system and acceptance testing. Test-driven development writes tests first. Code coverage measures what tests exercise. Debugging uses breakpoints, logging and bisection (git bisect). Dijkstra noted testing can show the presence of bugs but not their absence. The term 'bug' was popularised by Grace Hopper's team's moth log (1947).

Example

A unit test checks that a tax function returns 18% GST correctly.

Code

def gst(amount, rate=0.18):
    return round(amount * rate, 2)

def test_gst():
    assert gst(100) == 18.0
    assert gst(0) == 0

How it works, step by step

  1. Write tests for expected behaviour
  2. Run tests automatically (CI)
  3. Reproduce a failing case
  4. Isolate the cause
  5. Fix and add a regression test

Open the interactive page with diagrams →

People behind it

References

  1. K. Beck, Test-Driven Development: By Example, Addison-Wesley, 2002.

Textbooks

Related topics

Software engineering and version controlHuman–computer interaction and usabilityPython programming essentialsError-detecting and error-correcting codesClustering and unsupervised learningAlgorithms and Big-O complexityDecision trees and ensemble methodsSorting algorithms (quicksort, mergesort, heapsort)Reinforcement learningData structures: arrays, linked lists, stacks, queues