Writing the tests before the code only really works if there's an interface that's fully defined and well specified in advance. There are definitely times where that is the case, but in my experience it usually doesn't work like that.
It doesn't work like that because people are afraid to change things up. Lots of time people want to see working code that works for nominal use cases before hand.