I’m going to try to sell you TDD.
Take two people. Go to person 1 and say “You do whatever you think and we will see where you arrive at the end of the week”. Go to person 2 and say “I’m going to tell you where you need to go in order to deliver for me in this week”
Who are you being more fair too? – be honest.
Your business partners/users are telling you what they need. In a week it is better to show them that you made progress toward what they need and not what you like.
Given I visit /departments on our stock system, When I pass no category, I expect to see all departments. http://dev.service.com/departments - all departments.
Given I visit /departments on our stock system, When I do pass a category, I expect to see all departments in that category. http://dev.service.com/departments?category=boots - all emergency department.
You put that into a test like so.
def test_departments_url(self): results = self.test_client.get('/departments') self.assertEqual(results, ALL_DEPARTMENTS) results = self.test_client.get('/departments?category=boots') self.assertEqual(results, BOOTS)
Or even hit the full stack ( Eat your own dog food and be sure it works end to end )
> curl 'http://dev.dervice.com/departments?category' --header "Accept: application/json" > usecase-10001.test > diff usecase10001.test usecase10001.expected
Use your clients system all the time to ensure that your clients system behaves the your client wants. Capture the desired behavior in a test first. Show that the system cannot behave according to some requirement yet. Finally, expend only the effort needed to make the system behave according to your clients desire.
When using TDD you tend to write only the code you need and not the code that pops into your head. There is a temptation with programmers to write code for eventualities that will never come around. Remember
LESS CODE IS LESS ROAD!
Who wants to drive data down a needless long road of code. The longer your drive the more likely you are to crash. Driving across too much road also costs you fuel and unnecessary wear and tear.
Know better, do better 🙂 – “Captain Christopher Pike”