Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.



Programming and Learning from SD

Continuing my previous article on BDD, I wanted to point out some benefits of BDD and since BDD is an extension of Test Driven Development (TDD), you get those as well. I’ll add another article on some possible downsides of this approach.

There are many articles about the benefits of TDD and they apply to BDD. I’ve pointed out some here and copied some of the main points for each article, but there are many more including the book The Art of Unit Testing by Roy Osherove.

http://geekswithblogs.net/leesblog/archive/2008/04/30/the-benefits-of-test-driven-development.aspx (Lee Brandt)

  • Stability
  • Accountability
  • Design Ability
  • Separated Concerns
  • Progress Indicator

http://tddftw.com/benefits-of-tdd/

  • Help maintainers understand the intention behind the code
  • Bring validation and proper data handling concerns to the forefront.
  • Writing the tests first is fun.
  • Better APIs come from writing testable code.
  • TDD will make you a better developer.

http://www.slideshare.net/dhelper/benefit-from-unit-testing-in-the-real-world (from Typemock). Take a look at the slides, especially the extra time required for TDD (slide 10) and the next one of the bugs avoided using TDD (slide 11).

  • Less bugs (slide 11)
  • about testing and development (13)
  • Increase confidence in code (14)
  • Fearlessly change your code (14)
  • Document Requirements (14) also see http://visualstudiomagazine.com/articles/2013/06/01/roc-rocks.aspx
  • Discover usability issues early (14)
  • All these points and articles are great and there are many more. The following are my additions to the benefits of BDD from using it in real projects for my company.

July 2013 on MSDN - Behavior-Driven Design with SpecFlow

Scott Allen did a very informative TDD and MVC module, but to me he is doing BDD

Compile and Execute Requirements in Microsoft .NET ~ Video from TechEd 2012

    Communication

    I was working through a complicated task that the decision tree kept growing. After writing out the Given, When, Then of the scenario, I was able tell QA what I had worked through for their initial test cases. They were able to add from there. It is also useful to use this language with other developers, managers, or clients to help make informed decisions on if it meets the requirements or if it can simplified to save time (money).

    Thinking through solutions, before starting to code

    This was the biggest benefit to me. I like to jump into coding to figure out the problem. Many times I don't understand my path well enough and have to do some parts over. A past supervisor told me several times during reviews that I need to get better at seeing "the forest for the trees". When I sit down and write out the behavior that I need to implement, I force myself to think things out further and catch scenarios before they get to QA.

    A co-worker that is new to BDD and we’ve been using it in our new project for the last 6 months, said “It really clarifies things”. It took him awhile to understand it all, but now he’s seeing the value of this approach (yes there are some downsides, but that is a different issue).

    Developers’ Confidence

    This is huge for me. With tests in place, my confidence grows that I won’t break code that I’m not directly changing. In the past, I’ve worked on projects with out tests and we would frequently find regression bugs (or worse the users would find them). That isn’t fun. We don’t catch all problems with the tests, but when QA catches one, I can write a test to make sure it doesn’t happen again.

    It’s also good for Releasing code, telling your manager that it’s good to go.

    As time goes on and the code gets older, how confident are you that checking in code won’t break something somewhere else?

    Merging code - pre release confidence

    If you’re merging code a lot, it’s nice to have the tests to help ensure you didn’t merge incorrectly.

    Interrupted work

    I had a task that I started and planned out, then was interrupted for a month because of different priorities. When I started it up again, and un-shelved my changes, I had the BDD specs and it helped me remember what I had figured out and what was left to do. It would have much more difficult without the specs and tests.

    Testing and verifying complicated scenarios

    Sometimes in the UI there are scenarios that get tricky, because there are a lot of steps involved (click here to open the dialog, enter the information, make sure it’s valid, when I click cancel it should do {x}, when I click ok it should close and do {y}, then do this, etc….). With BDD I can avoid some of the mouse clicking define the scenarios and have them re-run quickly, without using a mouse. UI testing is still needed, but this helps a bunch.

    The same can be true for tricky server logic.

    Documentation of Assumptions and Specifications

    The BDD spec tests (Jasmine or SpecFlow or other tool) also work as documentation and show what the original developer was trying to accomplish. It’s not a different Word document, so developers will keep this up to date, instead of letting it become obsolete.

    What happens if you leave the project (consulting, new job, etc) with no specs or at the least good comments in the code?

    Sometimes I think of a new scenario, so I add a failing spec and continue in the same stream of thought (don’t forget it because it was on a piece of paper or in a notepad). Then later I can come back and handle it and have it documented.

    Jasmine tests and JavaScript –> help deal with the non-typed system

    I like JavaScript, but I also dislike working with JavaScript. I miss C# telling me if a property doesn’t actually exist at build time. I like the idea of TypeScript and hope to use it more in the future. I also use KnockoutJs, which has observables that need to be called with ending (), since the observable is a function. It’s hard to remember when to use () or not and the Jasmine specs/tests help ensure the correct usage.

     

    This should give you an idea of the benefits that I see in using the BDD approach. I’m sure there are more. It talks a lot of practice, investment and experimentation to figure out how to approach this and to get comfortable with it. I agree with Scott Allen in the video I linked above “Remember that TDD can take some practice. So if you're not doing test-driven design right now? You can start and practice and get better. And you'll reach a point where you'll never want to get back.”

    Posted on Friday, July 26, 2013 10:44 AM Productivity , Unit Testing , BDD , Tools | Back to top


    Comments on this post: Benefits of Behavior Driven Development

    # re: Benefits of Behavior Driven Development
    Requesting Gravatar...
    Very useful article!
    There is also an interesting one to read on this subject
    http://www.binary-studio.com/2014/4/25/bdd-specflow-watin-part-i
    Left by Diana on Apr 30, 2014 7:23 AM

    # re: Benefits of Behavior Driven Development
    Requesting Gravatar...
    This is a great summary list of the benefits of BDD. Thanks for sharing!
    Left by Rahi on Feb 28, 2015 7:39 PM

    # Benefits of Behavior Driven Development
    Requesting Gravatar...
    I'm glad to be reading this article, I simply want to offer you a huge thumbs up for your great information.
    Tableau Guru
    www.sqiar.com
    Left by SQIAR on Feb 02, 2016 2:24 AM

    Your comment:
     (will show your gravatar)


    Copyright © Aligned | Powered by: GeeksWithBlogs.net