Tuesday, 7 January 2014

Why Specification by Example?

Quite a lot of the time there is, should we say healthy debate within the project team when not everybody has the same opinions. And let's admit nobody ever has the same opinions of how software will or should be developed. 

I take this from recent personal experience and really wanted to highlight my view on this technique. 

I wanted to try and clarify some misunderstandings about what project teams are trying to achieve. 

As a team we are attempting to:
  • Create a shared understanding of the behaviour of the system to fulfil a user story by using specific, concrete worked examples to illustrate the required behaviour for a range of situations
  • Collaborate so that people provided their expertise and viewpoints on a story on the basis that different perspectives allow us to better consider what is required. As our Teamwork value says we are “better together than we are individually"
  • Create these examples in a format that can be shared between, and understood by, all members of the project team, both technical and non-technical – for example, business stakeholders as well as testers and developers

The benefits of this approach is that we:
  • Address ambiguity, misunderstandings and assumptions at the earliest point in the development lifecycle, i.e. before any code has been written. This is because it is cheaper and quicker in the long run to address this issues before we have wasted time building and testing the wrong things
  • Make sure we take into account the requirements from different stakeholders within the business – for example Security, Support teams etc – and also that we take into account what the current systems do so that we can achieve consistency, where applicable, rather than one person making up what they think the system should do

It is incredibly difficult for one person to fully define how a system should behave, even for a story, with all the various alternate paths the system could take, and be able to communicate this in a clear and consistent manner to all the people involved in the project. Working as a team will spark healthy conversations in order to define exactly what the business want.

In a meeting I chaired we seemed to end up in a discussion around the implementation of tests within the project, and this seemed to take a low-level, developer-centric approach. To me this is a separate issue, the key issue is that we need to look at what we want to develop and test, not how we are going to test it.

One advantage of writing our examples in a specific format – using a Given, When, Then syntax – is that it gives us the option to automate this using a tool such as SpecFlow but that doesn’t mean that other test tools aren’t available for us to use, whether that is a unit test framework, Fitnesse or DBFit, SoapUI or Selenium. However, another advantage of using this format is that it forces us to write them in a clear and consistent manner which helps us to communicate with all members of the project team, including non-technical ones, in a manner that a unit test suite never could. That doesn’t mean that we can’t write unit tests when we’re writing the low level code but we need to understand what our unit tests should be testing.

A key word to take from this is "Collaboration" this is what Specification by Example is all about. 

No comments:

Post a Comment