3 ms·
BDD encourages the developer to define a clear behavioral specification for the unit of functionality before you implement it. By first focusing on the usage I
by ollysb 17y ago
BDD encourages the developer to define a clear behavioral specification for the unit of functionality before you implement it. By first focusing on the usage I find that the abstractions I produce are simpler and in turn have fewer unit tests. I think the author is saying that TDD done well results in fewer tests for simpler code.
- jlouis 17y agoAll good code has the property of clear specification. The place where BDD really shines is that it forces you to use your own abstraction in practice, which often uncovers where it is unwieldy to use. Another way to get lean code is to use a proper, powerful, static type system. It enforces you to think about the code "skeleton" and the "tests" are done automatically by the type checker at each compile/load of the code. It also reduces the amount of testing needed: There is no way something different from an integer can be passed as a parameter, so you do not need to account for that. My code does not use many Unit tests per se. But it does autogenerate a lot of test cases to check certain properties. Autogeneration is excellent at producing corner-cases, so if that is what you are after... I generally find this is a better use of my time as a programmer: Better spend some time developing the autogenerator than writing boring tests which my code for most part will pass in first attempt.