Introduction
When software is tested, it is important to check it in different ways to find problems. Two main ways are black-box testing and white-box testing, which look at the software from different angles to catch errors.
Imagine buying a new phone. Black-box testing is like using the phone to see if the buttons and apps work without opening it. White-box testing is like a technician opening the phone to check the circuits and chips inside to make sure everything is connected properly.
┌───────────────────────┐ ┌───────────────────────┐
│ Black-box Testing │ │ White-box Testing │
│ │ │ │
│ Inputs → [Software] →│ │ Code → [Software] → │
│ Outputs │ │ Tests internal logic │
└───────────────────────┘ └───────────────────────┘
↑ ↑
│ │
No knowledge Full knowledge
of internal of internal code
workings and structuredef add(a: int, b: int) -> int: return a + b # Black-box test: Check output for input (2, 3) print(add(2, 3)) # Expected output: 5 # White-box test: Check if function handles zero correctly assert add(0, 0) == 0 assert add(-1, 1) == 0