Agile Technical Practices
Sandy Mamoli
@smamolwww.nomad8.com
unit testingacceptance testing
continuous integration
load testingrefactoring
TDD
pair programming
user stories
whole team
collective code ownership
coding standards
Quality
• Overview of Agile
• Agile Acceptance Testing
• Deployment pipeline (CI)
Agile
What is Agile?
• Software development framework
• Based on adaptive planning
• Used since 1995 (Scrum)
Responding to change
In Changed Form
Not Wanted Anymore
As Defined
In Changed Form Not Wanted Anymore As Defined
Features: 6 months
Standish Group, Chaos Report
How does it work?
Incrementing one bit at a time
51 2 3 4
© Jeff Patton, all rights reserved, www.AgileProductDesign.com
Vertical slices - feedback & innovation
© Johnathan Rasmussen, The Agile Samurai
Working, shippable software
Build important things first
Technical excellence
Continuous improvement
Agile Quality
Cost of bugs
0
37.5
75.0
112.5
150.0
A more scientific way of saying this ...
1x 5x 10x20x
50x
>150
Reqs Design Code DevT AccT OpsSource: Standish Group
Agile Testing Quadrants
Agile Acceptance TestFunctional TestStory Test
Unit Tests
The dev’s view
unit testing
acceptance testing
exploratory testing
User Stories
“incrementing” builds one bit at a time
51 2 3 4
© Jeff Patton, all rights reserved, www.AgileProductDesign.com
Story&ID:&
Descrip/on:
photographerAs&a&...
I&want&to&...
So&that&...make some photo albums private
I can have a backup of my personalphotos online
Priority:
Size:
high
13
Photo album privacy
Acceptance(Criteria
1. I can set the privacy of photo albums2. I can see my private albums3. My private albums are not visible to others
Agile Acceptance Testing
Agile Testing Quadrants
Agile Acceptance TestFunctional TestStory Test
Unit Tests
Acceptance tests
• Check that the implementation matches the intent
• Focus on shared understanding by developers, testers and business people
• End to end
Scenarios
• Create a new private album
• Make a public album private
• Make a private album public
<vertical slices through the acceptance criteria>
Examples
Given I create an album named “My holiday”
When I choose to make it private
Then I can see the album “My holiday”
But Kai cannot see the album
Examples
Given ... <something we accept to be true>
When ...<indicates the event in a scenario>
Then ...<indicates the expected outcome>
<Melomel API>
Cucumber
• Features
• Scenarios
• Steps
• Cucumber command
cucumber: example
Featurescucumber: example
Scenarioscucumber: example
Stepscucumber: example
Cucumber commandcucumber: example
Cucumber commandcucumber: example
Cucumber commandcucumber: example
Good practices
• Hide unnecessary detail
• Make tests independent
• Don’t test absolutely everything
Scenario: transfer money (imperative) Given I have $100 in checking
And I have $20 in savings
When I go to the transfer form
And I select "Checking" from "Source Account"
And I select "Savings" from "Target Account"
And I fill in "Amount" with "15" And I press "Execute Transfer" Then I should see that I have $85 in checking And I should see that I have $35 in savings
Declarative vs. imperative style
Declarative vs. imperative style
Scenario: transfer money (declarative) Given I have $100 in checking And I have $20 in savings When I transfer $15 from checking to savings Then I should have $85 in checking
Make tests independent
• Maintenance
• Where did it fail?
• Parallelise
Don’t test absolutely everything
Unit Tests
Acceptance Tests
GUI Tests
Why I like ATDD
• Ensures the intent is well understood
• Ensures the implementation matches the intent
• Ensures the implementation keeps matching the intent
Living documentation
Unit testing
Agile Testing Quadrants
Agile Acceptance TestFunctional TestStory Test
Unit Tests
Unit tests
• Check that the program behaves as the developer thinks it should
• Tend to be focussed on the structural (internal) quality of the code
• Hard for testers and business people to understand
• FlexUnit
• MXUnit
Unit tests/TDD
Deployment Pipeline
Agile Testing Quadrants
Agile Acceptance TestFunctional TestStory Test
Unit Tests
As often as possible to get early and instant feedback
Deployment pipeline
Deployment pipeline: Jez Humble, www.continuousdelivery.com
Agile deployment pipeline
Deployment pipeline: Jez Humble, www.continuousdelivery.com
• Create deployable artifacts
• Or fail fast and notify the team
• Triggered by CI server
• 5 minutes or less to run
• Jenkins, TeamCity, etc
Deployment pipeline: Commit stage
Continuous integration is a practice not a tool
• Commit regularly (at least once a day)
• Fix any broken build immediately
• Write automated tests
• Verify acceptance criteria have been met
• Verify business value
• Run in parallel
• Refactor
Deployment pipeline: Acceptance test stage
How to get started
• Create a walking skeleton with placeholders
• Automate the build and deploy process
• Automate unit tests and code analysis
• Automate acceptance tests
• Evolve the pipeline
Recommended reading
++
Call to action
• Work on Melomel & Cucumber
• Participate in CI projects (Jenkins)
• Steal from Ruby on Rails :-)
Contact meSandy Mamoli