Looking into a team’s experience with adopting Behavior-Driven Development (BDD) and at answering these questions:
- Why did we try it?
- What tools and processes did we adopt?
- How did it go?
3. What is BDD?
● Focuses on specifying behavior instead of
writing tests
● Defines a language for writing behaviors that
can be executed
o Gherkin - Given-When-Then statements
4. Why use BDD?
● functional, end-to-end testing
● communication
o with product owner
o with team members
● documentation
● building the right software
5. What’s wrong with TDD?
● Nothing
● Reading unit-tests harder for the business
6. What tools & processes did we use?
We were building a REST service with Java,
so…cucumber-jvm with groovy.
● simplified step-definition (vs Java)
Given(~'^an order with all details$') {->
@Given("^a vehicle exists$")
public void a_vehicle_exists() throws Throwable {
7. What tools & processes did we use?
● groovy - cucumber-spring integration
o wasn’t strong, but can be worked around
● Could’ve used unit testing directly
Scenario: place a valid order
Given an order with all details
When an order is placed
Then a "CREATED" response is returned
And the location of the new order is returned
And a confirmation number is returned
And the status is "ACTIVE"
def “place a valid order”() {
given: “an order with all details”
when: “an order is placed”
then: “a CREATED response is returned”
and: “the location of the new order is returned”
and: “a confirmation number is returned”
and: “the status is ACTIVE”
}
11. Reviews and Unit Testing
Code review focus
● Read tests first
Unit test changes
● Used the Spock given-when-then structure, often with
comments, to explain the test similar to Cucumber.
13. Story Breakdown
Difficulty with scrum story
breakdown and swarming
● Starting with Cucumber
feature left us feeling
constrained with how the next
steps would happen.
● How to get more than two
people on it and still feel
effective?
15. What would I do differently?
● Continue working on
involving product owner
● Create feature statements as part of story
creation
● Demonstrate progress through test report
16. Summary
● BDD was a good thing
● I think we should continue the practice
o though stronger business involvement is needed for
it to be truly effective
Points to cover:
We explored this with the Spock framework
Code would be between each line
Text wouldn’t read as easily
What people didn’t like:
Time it takes to run tests - they are functional, so they have to set up the world
Time it takes to develop
Developer needing to be a tester too