#development #test
A part of, [[A Breathing Approach to Solution Construction]].
TDD is a continuous, iterative process of improving code through tests. They serve as constraints that our implementation, regardless of its form, must verify to make sure we are developing the right solution.
Since we are either writing a feature or fixing an issue. I'd like to posit the following formula.
Correct understanding of the feature (or issue) leads the formulation of tests that negatively describe the solution (or successfully identify the cause of the issue).
The implementation runs through cycles of solution (or fix) proposals informed by test failures until all tests pass.
![[Tests and How to Do them 2024-04-30 16.41.13.excalidraw.png|100%]]
Tests are expectations on edge cases that we use just like pins that hold a piece of clothing in a desired form. The spirit is mostly of efficiency. We use just enough tests to describe the feature. On the other hand, we use just enough code to pass the test. This leads to simple and clean code.
Only ever write code to fix a failing test.
Tests breakdown into unit and integration tests. Unit tests are here to make sure individual components work as expected. While integration tests verify the interaction and communication between various components.
When building a test, we usually recognize 3 parts described below.
![[Implementing Unit Tests and Integration Tests in Python With Test Database and Mock Server#4Esk5AcUEe--Pd-suHuVLQ]]
![[Implementing Unit Tests and Integration Tests in Python With Test Database and Mock Server#rbKzcAcVEe-YF2MoBzp71A]]
More on, [[Testing in Python]] and [[Testing in Node.js Bun]]