DEVELOPING SOFTWARE WITH BEHAVIORS
Customer expectations, often, get lost in translation when they are handed off from product marketing, to development, quality assurance and finally to the operations team for delivery.
How do you define a common vocabulary for all stakeholders? How do you measure progress? And how do you know you have met customer expectations?
Behavior Driven Development (BDD), an agile software development process, can help! Here is how...
STEP 0: USER STORY
Customer expectations are captured in a user story.
“As a [role]
I want [feature]
So that [benefit]”
STEP 1: DEFINE CONTEXT
A context is defined using a "feature" as described below.
A feature includes:
- the user story we defined in Step 0
- scenarios or behaviors that are used to explain the use cases
In addition, for each scenario or behavior:
- preconditions are defined using the keyword "Given"
- an event trigger is defined using the keyword "When"
- an expected outcome or a verification is defined using the keyword "Then"
STEP 2: EVALUATE FOR CORRECTNESS
No we did not skip the "Develop Solution" step! Instead of waiting for tests to be implemented, we want instant feedback!
Similar to Test-driven Development (TDD), all our tests will initially fail. As developers commit the solution, our scenarios or behaviors will start passing.
All BDD frameworks include standard automated reporting structure such as JUnit, which can be integrated in Jenkins or other Continuous Integration Software tools. Hence, you don't have to track test case definitions and results in spreadsheets or test case repository systems.
STEP 3: DEVELOP SOLUTION
You will first develop the underlying code for the new feature. Then "steps" are added to translate the behaviors to your code.
It is possible for you to miss or misinterpret a requirement, in which case, you will have to modify the behavior, steps and code accordingly.
The process continues until all tests pass and all requirements are adequately satisfied. A software release decision can be made at this point.
STEP 4: DEPLOY & MONITOR
After your new software features have been deployed, feedback from operations and customers will be used to adjust your requirements and scenarios in subsequent releases.
RECAP
Behavior Driven Development(BDD), provides
- a common vocabulary for product owner, developers, quality assurance and operations team
- a complete feedback loop on overall feature progress (i.e. all tests initially fail then they start passing)
- automated reporting system (i.e. no need to invest into a test case repository system)
Common BDD frameworks are
- Behave for Python with several reporting plugins like JUnit
- Cucumber for Java, Ruby, Groovy and even Tcl!
BDD may be challenging to implement if your organization is not agile, large, located in multiple geographies, or does not follow the git flow process.
The Behave Examples and Tutorials is an excellent starting point for learning everything about BDD!