Growing softwarefrom examplesSeb	  Rose,	  Claysnow	  LimitedTwi$er:	  	  	  	  	  	  	  	  	  	  	  	  	  @sebroseBlog:	 ...
Test DrivenDevelopmentAcceptance TestDriven DevelopmentBehaviour DrivenDevelopmentDomain DrivenDesignSpecification by Examp...
Heavily influenced by GOOS book:
Pattern Generally good for Generally bad forGiven/When/ThenTests that require•a lot of setup OR•easily forgotten setupTest...
They’re called different thingsThe difference is that one is called BehaviourDriven Development – and some people find that...
Outside-inhttp://bddkickstart.com
http://exampler.com
UnderstandableDesirable propertiesGranularNecessaryMaintainableReliable
Understandablehttp://plus.maths.org/latestnews/sep-dec08/proof/proof.jpg
Maintainable
Necessary
Granular
Reliable
Work collaborativelyCreate a ubiquitous language.Use examples to discover the domain.Decompose ruthlessly.
Online subscriptionsIn order to make getting the magazine simplervisitors should be able tosubscribe online with a VISA ca...
VISA subscriptionsIn order to increase subscriptionsvisitors should be able tosubscribe online with a VISA cardAcceptance ...
Really? So tell me..."Customers should be prevented fromentering an invalid credit card number"• What exactly makes someon...
http://www.userdrivendev.com/p/user-language-inside-source-code.html
http://commitment-thebook.com
Remember your audienceWho should be able to read the examples?Keep things clear.What is their interest in them?
Don’t hide the context	 [Test]	 public void asterisk_should_format_to_emphasis()	 {String expected = "This is <em>em</em> ...
Don’t hide necessary contextScenario: Increased delivery charges for zip codeGiven my delivery zip code is in AlaskaWhen I...
Don’t hide important data	 @Test	 public void smoker_requires_manual_referral()	 {Referral referral = underwriting.process...
Make data explicit	 @Test	 public void smoker_requires_manual_referral()	 {Customer customer = new Customer(“Joe”, “Smith”...
Emphasise interesting details	 @Test	 public void smoker_requires_manual_referral()	 {CustomerBuilder builder = new Custom...
Declarative - makes a statement (.)Prefer declarative examplesExclamatory - shows excitement (!)Interrogative - asks a que...
Imperative vs Declarative StyleFeature: Sign upScenario: New user redirected to their own pageGiven I am not logged inAnd ...
Imperative vs Declarative StyleFeature: Sign upScenario: New user redirected to their own pageWhen I sign up for a new acc...
Imperative vs Declarative StyleFeature: The entire systemThis feature illustrates what can happen when youtake the declara...
Avoid workflow styleEvery journey is made from single steps.Workflows are more brittle.A few workflows go a long way.
https://www.ibm.com/developerworks/library/j-aopwork11/TestingPyramid.jpgExploratoryandmanual
Workflow styleScenario: Happy path for registration and purchaseGiven I am on the homepageAnd I register for an account in ...
Workflow style leads to repetitionScenario: Correct postage price for AlaskaGiven I am on the homepageAnd I register for an...
Focus on a single actionScenario: Correct postage price for AlaskaGiven I am on the checkout pageWhen I select delivery to...
Consider costs and benefitsRemove unnecessary examplesExercise the thinnest slice possibleAutomate when viable
CostRiskManualAutomate
Verify dependencies“Don’t mock what you don’t own” JoeWalnesTreat 2nd party code same as 3rd party.Contract and collaborat...
• A stub in a collaboration test mustcorrespond to an expected result in acontract test• An expectation in a collaboration...
Don’t let example dictatemechanismVisibility depends on interest not layer.Remember the intended audience.Acceptance tests...
http://claysnow.co.uk/?p=175315341
Make technical tests visibleScenario: High Risk rates for Test PilotsGiven an applicant with occupation “Test Pilot”When t...
Scenario: Applicant with high risk occupationGiven a standard, single-life, male applicantBut with a high risk occupationW...
Categorise in multiple dimensionsFaster feedback is better.Other dimensions are also useful.Take advantage of partitioning.
Examples are documentationRequirements.Living documentation.Automated regression tests.
https://www.relishapp.com/GDS/whitehall
NomenclatureTestExampleSpecification
http://www.slideshare.net/ehendrickson/the-thinking-tester-evolved
http://www.slideshare.net/ehendrickson/the-thinking-tester-evolved
NomenclatureTestExampleSpecificationCheck
What’s in a name?“... it doesnt take much to see thatthe problems of three little peopledont amount to a hill of beans in ...
SummaryExample-based methods are very similar.Minor variations by target audience.Skills are transferable.The naming genie...
Seb	  RoseTwi$er:	  	   @sebroseBlog:	  	   	   www.claysnow.co.ukE-­‐mail:	   	  	  	  	  	  seb@claysnow.co.uk
Growing software from examples
Growing software from examples
Growing software from examples
Upcoming SlideShare
Loading in...5
×

Growing software from examples

1,437

Published on

This presentation has been given at ScanDev 2013 and XP 2013. It's also going to be given at NDC 2013 later this week.

The key message is that there is a huge amount in common between the various example-based development techniques. The differences are minor and mainly due to the background of the technique and its intended audience.

0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,437
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
0
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Growing software from examples

  1. 1. Growing softwarefrom examplesSeb  Rose,  Claysnow  LimitedTwi$er:                          @sebroseBlog:       www.claysnow.co.ukE-­‐mail:     seb@claysnow.co.uk
  2. 2. Test DrivenDevelopmentAcceptance TestDriven DevelopmentBehaviour DrivenDevelopmentDomain DrivenDesignSpecification by ExampleExample DrivenDevelopmentCustomerTest?
  3. 3. Heavily influenced by GOOS book:
  4. 4. Pattern Generally good for Generally bad forGiven/When/ThenTests that require•a lot of setup OR•easily forgotten setupTests that have a non-obvious triggerTests with few expected outputs• Tests that have unimportant/simple/obvious preconditions• Tests where there are multipledifferent inputs and multipledifferent outputs• Tests where a single Given/When/Then only describes oneof numerous very similar testscenarios•Specification ByExample -Conceptual orConcreteTests that have numerous:Inputs that affect output behaviorOutputs/expected behaviorsTests where it’s important to test a lotof different data scenariosTests where the trigger event issomewhat obviousAny test where it seems like a tablewould be useful to:describe the test better, orhelp explore all of the possibleinputs and outputs for a test.• Simple tests• Tests that are more aboutverifying simple UI behaviorFor instance – “Test that anerror message is displayed whenthe user enters an incorrectpassword.”• Test where there is really onlyone input or preconditionhttp://www.scrumcrazy.com/file/view/ScrumCrazy.com_StoryTestingPatternsSummary3.pdf/391066838/ScrumCrazy.com_StoryTestingPatternsSummary3.pdf
  5. 5. They’re called different thingsThe difference is that one is called BehaviourDriven Development – and some people find thatwording useful – and one (or two) is called(Acceptance) Test Driven Development – andsome people find that wording useful in adifferent way.And that’s it.Liz Keogh, 2011http://lizkeogh.com/2011/06/27/atdd-vs-bdd-and-a-potted-history-of-some-related-stuff/
  6. 6. Outside-inhttp://bddkickstart.com
  7. 7. http://exampler.com
  8. 8. UnderstandableDesirable propertiesGranularNecessaryMaintainableReliable
  9. 9. Understandablehttp://plus.maths.org/latestnews/sep-dec08/proof/proof.jpg
  10. 10. Maintainable
  11. 11. Necessary
  12. 12. Granular
  13. 13. Reliable
  14. 14. Work collaborativelyCreate a ubiquitous language.Use examples to discover the domain.Decompose ruthlessly.
  15. 15. Online subscriptionsIn order to make getting the magazine simplervisitors should be able tosubscribe online with a VISA cardUser / Stakeholder Story
  16. 16. VISA subscriptionsIn order to increase subscriptionsvisitors should be able tosubscribe online with a VISA cardAcceptance Criteria•Must support VISA•Does not need to support MasterCard, Switch•...•Customers should be prevented from entering aninvalid credit card number• ...Credit Card ProcessingAcceptance criteria:
  17. 17. Really? So tell me..."Customers should be prevented fromentering an invalid credit card number"• What exactly makes someonescredit card number invalid?• Can they use spaces?• Should we checksum the digits?• How do we feed back that the detailsare invalid?
  18. 18. http://www.userdrivendev.com/p/user-language-inside-source-code.html
  19. 19. http://commitment-thebook.com
  20. 20. Remember your audienceWho should be able to read the examples?Keep things clear.What is their interest in them?
  21. 21. Don’t hide the context [Test] public void asterisk_should_format_to_emphasis() {String expected = "This is <em>em</em> text";String actual = f.Format("This is *em* text"); Assert.AreEqual(expected, actual); }
  22. 22. Don’t hide necessary contextScenario: Increased delivery charges for zip codeGiven my delivery zip code is in AlaskaWhen I go to the checkoutThen I will have to pay the higher delivery charges
  23. 23. Don’t hide important data @Test public void smoker_requires_manual_referral() {Referral referral = underwriting.process(smoker);Assert.assertEquals(Referral.Manual, referral); }
  24. 24. Make data explicit @Test public void smoker_requires_manual_referral() {Customer customer = new Customer(“Joe”, “Smith”,“12/12/1980”, “Accountant”, “$300,000”, “Yes”,“No”);Referral referral = underwriting.process(customer);Assert.assertEquals(Referral.Manual, referral); }
  25. 25. Emphasise interesting details @Test public void smoker_requires_manual_referral() {CustomerBuilder builder = new CustomerBuilder();Customer customer = builder.withSmokerFlag().build();Referral referral = underwriting.process(customer);Assert.assertEquals(Referral.Manual, referral); }
  26. 26. Declarative - makes a statement (.)Prefer declarative examplesExclamatory - shows excitement (!)Interrogative - asks a question (?)Imperative - makes a command (.)
  27. 27. Imperative vs Declarative StyleFeature: Sign upScenario: New user redirected to their own pageGiven I am not logged inAnd I visit the homepageAnd I follow "Sign up"And I fill in "Username" with "Seb"And I fill in "Password" with "password"And I fill in "Confirm password" with "password"When I press "Sign up"Then I should be on my feeds pageAnd I should see "Hello, Seb"
  28. 28. Imperative vs Declarative StyleFeature: Sign upScenario: New user redirected to their own pageWhen I sign up for a new accountThen I should be taken to my feeds pageAnd I should see a greeting message
  29. 29. Imperative vs Declarative StyleFeature: The entire systemThis feature illustrates what can happen when youtake the declarative style too far.Scenario: It worksWhen I use the systemThen it should work perfectly
  30. 30. Avoid workflow styleEvery journey is made from single steps.Workflows are more brittle.A few workflows go a long way.
  31. 31. https://www.ibm.com/developerworks/library/j-aopwork11/TestingPyramid.jpgExploratoryandmanual
  32. 32. Workflow styleScenario: Happy path for registration and purchaseGiven I am on the homepageAnd I register for an account in AlaskaAnd I go to the most popular item pageAnd I add the most popular item to my basketAnd I go to checkoutAnd I select my delivery addressAnd I give valid payment detailsWhen I confirm acceptance of terms and conditionsThen my purchase will be confirmed
  33. 33. Workflow style leads to repetitionScenario: Correct postage price for AlaskaGiven I am on the homepageAnd I register for an account in “Alaska”And I go to the most popular item pageAnd I add the most popular item to my basketAnd I go to checkoutWhen I select delivery to my home addressThen I have to pay the higher delivery charge
  34. 34. Focus on a single actionScenario: Correct postage price for AlaskaGiven I am on the checkout pageWhen I select delivery to “Alaska”Then I have to pay the higher delivery charge
  35. 35. Consider costs and benefitsRemove unnecessary examplesExercise the thinnest slice possibleAutomate when viable
  36. 36. CostRiskManualAutomate
  37. 37. Verify dependencies“Don’t mock what you don’t own” JoeWalnesTreat 2nd party code same as 3rd party.Contract and collaboration tests.
  38. 38. • A stub in a collaboration test mustcorrespond to an expected result in acontract test• An expectation in a collaboration test mustcorrespond to an action in a contract testJ.B. Rainsberger, GOOS mailing list 15 March 2012Contract and collaboration tests
  39. 39. Don’t let example dictatemechanismVisibility depends on interest not layer.Remember the intended audience.Acceptance tests not always end-to-end.
  40. 40. http://claysnow.co.uk/?p=175315341
  41. 41. Make technical tests visibleScenario: High Risk rates for Test PilotsGiven an applicant with occupation “Test Pilot”When the underwriting engine is invokedThen we will use the “High Risk” rates table
  42. 42. Scenario: Applicant with high risk occupationGiven a standard, single-life, male applicantBut with a high risk occupationWhen the application is processedThen it will be referred for manual underwritingIs this end to end?@domain_model@stubbed_persistence
  43. 43. Categorise in multiple dimensionsFaster feedback is better.Other dimensions are also useful.Take advantage of partitioning.
  44. 44. Examples are documentationRequirements.Living documentation.Automated regression tests.
  45. 45. https://www.relishapp.com/GDS/whitehall
  46. 46. NomenclatureTestExampleSpecification
  47. 47. http://www.slideshare.net/ehendrickson/the-thinking-tester-evolved
  48. 48. http://www.slideshare.net/ehendrickson/the-thinking-tester-evolved
  49. 49. NomenclatureTestExampleSpecificationCheck
  50. 50. What’s in a name?“... it doesnt take much to see thatthe problems of three little peopledont amount to a hill of beans in thiscrazy world.”Humphrey Bogart “Casablanca”
  51. 51. SummaryExample-based methods are very similar.Minor variations by target audience.Skills are transferable.The naming genie is out of the bottle.Collaboration is key.
  52. 52. Seb  RoseTwi$er:     @sebroseBlog:       www.claysnow.co.ukE-­‐mail:            seb@claysnow.co.uk

×