pragmatic Test Driven Development

As a dev, I write mostly unit tests and care about test coverage increasing over time.  My view has shifted recently.

Although web UI tests can be fragile, they present a lot of bang for the buck, coverage-wise.  It turns out they also have a lot of unique business value; that is, if we’re testing what our users see, then when we change something we can immediately know that business value is being affected.

– I recommend view-level tests. Django directly supports and advocates this style. They’re fast and easy to create like Unit tests, but have direct user-level (thus business-level) value.

– for UI tests, set an ID on everything that you are testing. (Never ever use XPath.)  This makes UI tests more durable and reliable. 

– Kent Beck has been the main proponent of TDD from the very beginning, as part of Extreme Programming. “I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence”

– I really enjoy Brian Okken’s entirely pragmatic view on testing:
My reaction to “Is TDD Dead?”  His podcast is in my Top 3: Python Testing