Hi!
Assume we have a class UserService
with attribute current_user
. Suppose it is used in AppService
class.
We have AppService
covered with tests. In test setup we stub out current_user
with some mock value:
UserService.current_user = 'TestUser'
Assume we decide to rename current_user
to active_user
. We rename it in UserService
but forget to make change to its usage in AppService
.
We run tests and they pass! Test setup adds attribute current_user
which is still (wrongly but successfully) used in AppService
.
Now our tests are useless. They pass but application will fail in production.
We can't rely on our test suite ==> TDD is not possible.
Is TDD broken in Python?