tags:

views:

51

answers:

1

Hi Guys and Gals,

I'm new to BDD, and using SpecFlow I'm trying to work out an efficient, organised, and maintainable methodology(for use within ASP.NET MVC). The main areas I need to improve on are:

  • Grouping of steps (into step files)

  • Reusing test objects (like it is so easy to in unit tests by inheriting test base classes etc)

  • Folder structure

when it comes to grouping, let's take a typical CRUD scenario. For example:

  • a folder for each "area" in my project eg public, site management

  • a feature folder and step folder inside each of those

And then, inside those folders I've got one Feature file covering the whole CRUD experience for a certain entity e.g NewsItem. I've gone this way so that I can reuse objects and the NewsController in my steps.

But this means the step files get pretty huge covering all types of valid, invalid input possibilites and it is very hard to follow one scenario through all the way through. But if I don't, I can't reuse the steps that may be applicable to multiple scenario in the whole CRUD process.

I understand this is very subjective, and I'm not afraid to be overwhelmed by a number of different ideas and perspectives - that's what I want :P

As well as your own opinions & preferences, links to blogs and books would be good.

Thanks

Nick

A: 

Hi Nick,

Sorry nobody has answered this for ages. If it's still useful to you, this might help.

I keep my steps at a very high level: see this question http://stackoverflow.com/questions/3466083/imperative-and-declarative-steps-in-rspec

I group steps by areas of concern. Imagine logging in and performing some action, then logging out again. Or maybe going home for the day. Anything which I might do in one session becomes one area of concern. For instance, if I am a pet shop owner, I might have step files for: handling pets in stock, handling accessories and other stock, selling items, tracking profit, etc.

I also have a screen / page paradigm rather like WebDriver. This means that if a step actually does several things on the UI, there is one screen or page which handles all of those actions.

I often use cascading constructors to allow my BDD harness (in my case, plain old NUnit) to create these steps and scenarios for me. I've been writing a little automation tool and you can see some of these techniques in its examples:

http://code.google.com/p/wipflash/source/browse/Example.PetShop.Scenarios/PetRegistrationAndPurchase.cs

I haven't messed around much with SpecFlow yet, but I imagine these might be useful to you. It's the same design pattern that I've also used with JBehave or Fitnesse.NET and FitSharp.

Good luck! There's a BDD group http://groups.google.com/group/behaviordrivendevelopment which might help you if you need more info.

Lunivore