BDD: Behavior vs. Spec Frameworks

In my search to understand a little more about BDD and BDD frameworks, one gem that I gleaned is that there is an important distinction between “Spec” and “Behavior” frameworks. “Spec” is intended for the unit level granularity (like unit tests) and “Behavior” is intended to relay user stories at the application level.

This makes sense to me because in all the BDD discussions I’ve seen I had a hard time understanding why you want to put an application level story on top of a unit level story. it just didn’t make sense.

So here’s what I get so far (correct me):

I can use Behavior Frameworks to create stories that use the same shared language that my customer would understand, at the application level use cases. Most frameworks that support this allow you to “code” this up which still has a lot of friction for most people to read so it’s a problem.

I can use Spec Frameworks to replace the language I use in my current unit tests so that instead of “testing” I am defining “behavior” of a component at the unit level. this is usually almost a purely syntactical change in nature.

Some Frameworks have APIs for both Specs and Behaviors (like RSpec). Some only have APIs for one of them (which ones?)

Published Saturday, October 04, 2008 5:49 PM by RoyOsherove
Filed under: , ,

Comments

Sunday, October 05, 2008 8:14 AM by Dew Drop - October 5, 2008 | Alvin Ashcraft's Morning Dew

# Dew Drop - October 5, 2008 | Alvin Ashcraft's Morning Dew

Pingback from  Dew Drop - October 5, 2008 | Alvin Ashcraft's Morning Dew

Sunday, October 05, 2008 12:05 PM by Mark Needham

# re: BDD: Behavior vs. Spec Frameworks

I only just came across this realisation last week as well. I had thought the actual BDD concept was just for acceptance tests - JBehave is an example of a library where this is the case.

I have been writing unit tests in a similar way (see www.markhneedham.com/.../bdd-style-unit-test-names for more details) but there is no framework as such involved, just plain old NUnit or JUnit

Sunday, October 05, 2008 12:17 PM by Colin Jack

# re: BDD: Behavior vs. Spec Frameworks

Yup thats an important distinction and by not making it clearly BDD has become very confusing. To me the two variants are:

1. xBehave/Dan North/Acceptance testing

2. xSpec/Dave Astels/Improved TDD

Sunday, October 05, 2008 3:56 PM by Scott Bellware

# re: BDD: Behavior vs. Spec Frameworks

This is utterly, completely, and irresponsibly inaccurate... but everyone is repeating the same mantra after doing "research", so no harm, no foul.

If your research involves merely reading what the parrots on the web are parroting, then you're bound to come to this conclusion.  Nonetheless, it's an inaccurate and sadly misleading conclusion, and we really should be doing more tangible research rather than reporting merely on what others are saying.

Firstly what you're calling "behavior" frameworks are actually referred to specifically as "scenario" frameworks.

xSpec and xBehave are BOTH behavior frameworks.  The only significant difference is the grammar used to express behaviors.

Secondly, the differentiation of purpose between framdeworks - xBehave for functional specification and xSpec for unit specification - didn't come about because of the nature of the frameworks, but because of a concession made to Dan North who had something specific in mind with "BDD" that Dave Astels interpreted differently.

This division of responsibility of frameworks is more of an arbitrary truce between framework perspectives and is no more of a natural division than building a wall through the middle of Germany at the end of the second world war and calling one half communist and the other half capitalist.

The history of the differentiation is entirely political.  Either framework can be used for either purpose.  There is only a very small wedge of cases where either is more applicable than the other.

Sunday, October 05, 2008 3:58 PM by Colin Jack

# re: BDD: Behavior vs. Spec Frameworks

In case its useful I thought I'd put up a link to a blog entry I wrote a while back on this:

colinjack.blogspot.com/.../bdd-two-approaches.html

Sunday, October 05, 2008 4:21 PM by Colin Jack

# re: BDD: Behavior vs. Spec Frameworks

@Scott

"Secondly, the differentiation of purpose between framdeworks - xBehave for functional specification and xSpec for unit specification - didn't come about because of the nature of the frameworks, but because of a concession made to Dan North who had something specific in mind with "BDD" that Dave Astels interpreted differently."

As you say Asels/North seem to have had slightly different takes on BDD and that informed the paths they took and the resulting frameworks.

Plus I think we'd agree that focussing on the frameworks is the wrong approach, and to be honest i've done the majority of my BDD just with xUnit and tools like Watin where needed.

However I think Roy still has a point in saying that xBehave is primarily aimed for user story/acceptance testing.

Sunday, October 05, 2008 5:57 PM by Scott Bellware

# re: BDD: Behavior vs. Spec Frameworks

Colin,

We are presently using the GWT scenario grammar for directly testing stored procedures.

My experience with both framework grammars contradicts the oft-perpetuated commentary on which problems each framework addresses.

There are indeed differences between the behaviors, and those differences can be significant.  I've yet to see anyone objectively writing about these differences in context of problems which they solve.  More often I see folks simply stating the overly-simplistic "xBehave for functional specification, and xSpec for unit specification."

This perspective is rooted in trying to see BDD through TDD glasses without the awareness that we're wearing TDD glasses, or even that TDD-colored glasses exist.

It's a question of subtle but powerful change in paradigm, and our typical inability to become aware of new paradigms because of the biases we build up when we become attached and identified with a preceding practice.

# James Thigpen / Capture.Exception - BDD-esque w/ NUnit or: The Ikea Nightstand

Pingback from  James Thigpen  / Capture.Exception - BDD-esque w/ NUnit or: The Ikea Nightstand

Wednesday, October 08, 2008 8:08 AM by Colin Jack

# re: BDD: Behavior vs. Spec Frameworks

@Scott

Yeah I don't disagree, my feeling is just that acceptance testing poses a couple of additional challenges which make composition more useful.

I also feel like a lot of blog entries talk about BDD without taking much account of what Dan North described which leads to confusion, I think thats a big problem and one that I hope is gradually addressed.