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
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
- Write tests for expected behaviour
- Run tests automatically (CI)
- Reproduce a failing case
- Isolate the cause
- Fix and add a regression test
Open the interactive page with diagrams →
People behind it
- Edsger Dijkstra (1930–2002), Computer science, Netherlands: Invented the shortest-path algorithm, semaphores and structured programming. Turing Award 1972.
- Kent Beck
- Grace Hopper (1906–1992), Computer science, USA: US Navy rear admiral; built the first compiler (A-0) and influenced COBOL.
References
- K. Beck, Test-Driven Development: By Example, Addison-Wesley, 2002.
Textbooks
- The Mythical Man-Month, Frederick P. Brooks Jr. (Addison-Wesley, anniversary ed. 1995). Classic essays on software projects.
- Design Patterns: Elements of Reusable Object-Oriented Software, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides (Addison-Wesley, 1994). The 'Gang of Four' book.
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