I'm very new to TDD world. I have a few questions regarding TDD.
Do I have to do test-first in TDD? I heard that TDD is not about test. It's about design. I'm agreed that it's good to do test-first but what I like to know is that is it still TDD if we follow the test-last approach?
Shall we prefer to use BDD over TDD? I used to list out the specification of my task first and I try to write the test case based on my specification. Is it wrong approach? Do you guys prefer using BDD or TDD for your development?
Mocking? Some people from my team used to say that they are praticsing TDD. But they never follow test-first approach. they never mock the data. Do we have to mock the data in TDD?
"Using Mock Library" Vs "creating the mock class with data manually". Do you prefer to use mock library or create the mock classes with some mock data?
Any recommended book for TDD or BDD? I read Kent Beck's classic Test-Driven Development - By Example. I found that this book is published in very early stage of TDD so some of the things in this book are not a bit outdated.
1). Do I have to do test-first in TDD? I heard that TDD is not about test. It's about design. I'm agreed that it's good to do test-first but what I like to know is that is it still TDD if we follow the test-last approach?
Yes! Strictly speaking TDD is Test-Driven Development. So the development is driven by the test. So you test first, then develop program to pass all tests.
2). Shall we prefer to use BDD over TDD? I used to list out the specification of my task first and I try to write the test case based on my specification. Is it wrong approach? Do you guys prefer using BDD or TDD for your development?
I think you should balance them. Use other technique to provide overall design first as best as time provide (do risk management to find appropriate time you should spend on designing) (Find a paper about "RUP essential". It give quite a good idea about balancing agile and less-agile). Identify the most critical parts then creates test and develop to pass the test.
3).Mocking? Some people from my team used to say that they are praticsing TDD. But they never follow test-first approach. they never mock the data. Do we have to mock the data in TDD?
Test-first and mocking is not the same thing. Mocking allows code to be more testable as well as be testable when other part (which this code relies on) does not exist. So if there is no such dependency (IF!!), then you can to not mock them. (Read "Working Effectively with Legacy Code" about Seam point for more details).
4). "Using Mock Library" Vs "creating the mock class with data manually". Do you prefer to use mock library or create the mock classes with some mock data?
I think it just like using someone-else library or create yourown. Totally depends on the situation and many factors. For example, if you project is big and you can find appropriate mock library, use it.
5). Any recommended book for TDD or BDD? I read Kent Beck's classic Test-Driven Development - By Example. I found that this book is published in very early stage of TDD so some of the things in this book are not a bit outdated.
There are list of books on TDD here.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With