-
How can you tell if a code has been written using #TDD? I read you and I give opinion in the thread 👇
-
I go for obvious hints: - tests structure - git history Yet, when the tests are there and there's no clear hint in the logs, I start looking at different things.
-
The complexity of the first two tests tells me how much the dev knew about the solution Usually, with TDD, you start with the most simple scenario and keep iterating over there. If the first test has the same complexities as others, it can be a hint for test last Or a refactor
-
Another thing I watch for is the setup complexity depending if it's a model or a service. When I see difficult ways to test a Model, I can tell the test was written last. Or even mocks in the model. I even saw reflection being used because the constructor was private
-
TDD also helps in good Dependency Injection, and separation of responsibility. When the test suite does too much things, it's probably that the code was created first and then the test to prove the whole feature to work.
-
By this, you find a test pyramid that doesn't look like a pyramid. More like a flat guilding or inverted pyramid