Imperfect tests run frequently are better than perfect tests which are never written
assertionsfor things you believe will/should never happen.
exceptionsfor anomalous or exceptional conditions requiring special processing.
def kelvin_to_celsius(temp_k): """ Converts temperature in Kelvin to Celsius. """ assert temp_k >= 0.0, "ERROR: negative T_K" temp_c = temp_k + 273.15 return temp_c
Image by @thepracticaldev, CC-BY-NC.
- For which situations would you consider automated testing as overkill?
Assertions, exceptions, unit tests, integration tests and regression tests are used to test a code on different levels
Test driven development is one way to develop code which is tested from the start
Continuous integration is when every commit/merge is tested automatically