- BDD is (largely) good for integration / acceptance testing - Cucumber, with its whole language parsing regexy madness, feels overblown most of the time, and gets unmanageable quickly in bigger projects. It's really hard to navigate / organise / refactor steps. - There are alternatives that give you the benefits of BDD with the benefits of actually being code, sacrificing the ability for business people to write steps - see Steak and Pea (I wrote Pea when I was annoyed with Cucumber, it's not really maintained but it shows the idea) - The idea of "business people writing steps" is usually rubbish anyway. They might as well write it in prose and a developer convert it to code, because you generally can't write valid cucumber scenarios without a keen knowledge of how the steps are actually implemented. A good DSL should be just as readable to non-developers as Cucumber, if you ignore all the dots and brackets ;) - Running each line as it's encountered without any richer ability to delimit or contextualize things like you might in code really screws you up when you want to describe state in more than one step. So you either have to (1) make huge unwieldy steps ("I have an inactive user with a profile and a phone number of "blah" and address of "blah" [...]") so that you have a complete and valid state when you create your data, or (2) you have a series of small, composable steps that just register individual parts of the complete state, followed by a relatively-meaningless "now do it" step to actually perform the setup, or (3) you invent clever hacks that accumulate state in all the "Given" steps, and validate / execute it on the first "When" step. That last one was fun to do, but way more effort than it was worth ;)
Thanks Tim! I hadn't actually taken a proper look at Cucumber (I hadn't even seen the syntax until today!) I think most people consider excessively free-form languages to generally be a bad idea (looking at you COBOL).
I actually quite like the look of Pea, but I might just be biased as both a programmer and being on the Python side of the scripting language fence. :)
Certainly planning on doing a bit more reading on BDD - anything that helps people get a clearer idea on writing tests is a good thing!