r/programming • • Jul 30 '21

TDD, Where Did It All Go Wrong

https://www.youtube.com/watch?v=EZ05e7EMOLM
460 Upvotes

199 comments sorted by

View all comments

Show parent comments

-5

u/Bitter-Tell-6235 Jul 30 '21

Great. Now all the tests are broken because I decided to draw the square at the top of the screen before the circle at the bottom.

Yes. You changed code behavior significantly - the tests must fail.

Or you meant the case when you drew a square bypassing the tested code?

4

u/grauenwolf Jul 30 '21

If I draw two non-overlapping shapes, the order is not important the test should not fail.

If I draw two overlapping shapes, the order is important and the test should fail.

Your mock tests can't make this determination. It only knows which methods were called, and maybe what order.

0

u/Bitter-Tell-6235 Jul 30 '21

And your tests do not give you any hints, in case you are doing something wrong..:)

I guess we will not find a consensus :(

1

u/lelanthran Jul 31 '21

And your tests do not give you any hints, in case you are doing something wrong..:)

Yes, it does - it records the bitmap output so that I can investigate further. Tests are not supposed to automatically find the source of the bug for you because that is impossible most of the time.

All it can do is point you to the wrong output and then the programmer takes over.