Growing software from examples
description
Transcript of Growing software from examples
![Page 1: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/1.jpg)
Growing softwarefrom examples
Seb Rose, Claysnow Limited
Twitter: @sebrose
Blog: www.claysnow.co.uk
E-mail: [email protected]
![Page 2: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/2.jpg)
Heavily influenced by GOOS book:
![Page 3: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/3.jpg)
![Page 4: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/4.jpg)
![Page 5: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/5.jpg)
They’re called different thingsThe difference is that one is called Behaviour Driven Development – and some people find that wording useful – and one (or two) is called (Acceptance) Test Driven Development – and some people find that wording useful in a different way.
And that’s it. Liz Keogh, 2011http://lizkeogh.com/2011/06/27/atdd-vs-bdd-and-a-potted-history-of-some-related-stuff/
![Page 6: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/6.jpg)
Test Driven
Development
Acceptance Test
Driven
DevelopmentBehaviour
Driven Development
Domain Driven DesignSpecification by Example
Example
Driven
Development
Customer Test
![Page 7: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/7.jpg)
Pattern Generally good for Generally bad for
Given/When/Then
Tests 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 multiple different inputs and multiple different outputs
•Tests where a single Given/When/Then only describes one of numerous very similar test scenarios
Specification By Example - Conceptual or Concrete
Tests that have numerous:Inputs that affect output behaviorOutputs/expected behaviorsTests where it’s important to test a lot of different data scenariosTests where the trigger event is somewhat obviousAny test where it seems like a table would be useful to:describe the test better, orhelp explore all of the possible inputs and outputs for a test.
•Simple tests•Tests that are more about
verifying simple UI behavior
For instance – “Test that an error message is displayed when the user enters an incorrect password.”
•Test where there is really only one input or precondition
http://www.scrumcrazy.com/file/view/ScrumCrazy.com_StoryTestingPatternsSummary3.pdf/391066838/ScrumCrazy.com_StoryTestingPatternsSummary3.pdf
![Page 10: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/10.jpg)
UnderstandableMaintainableNecessaryGranularReliable
![Page 11: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/11.jpg)
Understandable
http://plus.maths.org/latestnews/sep-dec08/proof/proof.jpg
![Page 12: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/12.jpg)
Maintainable
![Page 13: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/13.jpg)
Necessary
![Page 14: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/14.jpg)
Granular
![Page 15: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/15.jpg)
Reliable
![Page 16: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/16.jpg)
Declarative - makes a statement (.)
Prefer declarative examples
Exclamatory - shows excitement (!)
Interrogative - asks a question (?)
Imperative - makes a command (.)
![Page 17: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/17.jpg)
Imperative vs Declarative Style
Feature: Sign up Scenario: New user redirected to their own page Given I am not logged in And I visit the homepage And 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 page And I should see "Hello, Seb"
![Page 18: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/18.jpg)
Imperative vs Declarative Style
Feature: Sign up Scenario: New user redirected to their own page When I sign up for a new account
Then I should be taken to my feeds pageAnd I should see a greeting message
![Page 19: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/19.jpg)
Imperative vs Declarative Style
Feature: The entire system This feature illustrates what can happen when you take the declarative style too far.
Scenario: It works When I use the system Then it should work perfectly
![Page 20: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/20.jpg)
Remember your audience
Who should be able to read the examples?
Keep things clear.
What is their interest in them?
![Page 21: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/21.jpg)
Don’t hide the context
[Test] public void asterisk_should_format_to_em() {String expected = "This is <em>em</em> text";String actual = f.Format("This is *em* text");
Assert.AreEqual(expected, actual); }
![Page 22: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/22.jpg)
Don’t hide the context
Scenario: 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
![Page 23: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/23.jpg)
Don’t hide the context
@Test public void smoker_requires_manual_referral() {Referral referral = underwriting.process(smoker);
Assert.assertEquals(Referral.Manual, referral); }
![Page 24: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/24.jpg)
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); }
![Page 25: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/25.jpg)
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); }
![Page 26: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/26.jpg)
Work collaboratively
Create a ubiquitous language.
Use examples to discover the domain.
Decompose ruthlessly.
![Page 27: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/27.jpg)
Online subscriptionsIn order to increase subscriptions
visitors should be able to
subscribe online with a VISA card
User / Stakeholder Story
![Page 28: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/28.jpg)
VISA subscriptionsIn order to increase subscriptions
visitors should be able to
subscribe online with a VISA card
User / Stakeholder Story
![Page 29: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/29.jpg)
VISA subscriptionsIn order to increase subscriptions
visitors should be able to
subscribe online with a VISA card
Acceptance Criteria
•Must support VISA•Does not need to support MasterCard, Switch•...•Customers should be prevented from entering invalid credit card details• ...
Credit Card ProcessingAcceptance criteria:
![Page 30: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/30.jpg)
Really? So tell me...
"Customers should be prevented from entering invalid
credit card details"
•What exactly makes someone's credit card details invalid?
•Can they use spaces?
•Should we checksum the digits?
•How do we feed back that the details are invalid?
![Page 31: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/31.jpg)
Avoid workflow style
Every journey is made from single steps.
Workflows are more brittle.
A few workflows go a long way.
![Page 32: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/32.jpg)
https://www.ibm.com/developerworks/library/j-aopwork11/TestingPyramid.jpg
Exploratory and
manual
![Page 33: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/33.jpg)
Workflow style
Scenario: 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
![Page 34: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/34.jpg)
Workflow style
Scenario: 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
![Page 35: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/35.jpg)
Focus on a single step
Scenario: 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
![Page 36: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/36.jpg)
Consider costs and benefits
Remove unnecessary examples
Exercise the thinnest slice possible
Automate when viable
![Page 37: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/37.jpg)
Cost
Risk
Manual
Automate
![Page 38: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/38.jpg)
Don’t let example dictate mechanism
Visibility depends on interest not layer.
Insulate examples from technical details.
Acceptance tests not always end-to-end.
![Page 39: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/39.jpg)
![Page 40: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/40.jpg)
Make technical tests visible
Scenario: 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
![Page 41: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/41.jpg)
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 underwriting
Is this end to end?
@domain_model@stubbed_underwriting
![Page 42: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/42.jpg)
Categorise in multiple dimensions
Faster feedback is better.
Other dimensions are also useful.
Take advantage of partitioning.
![Page 43: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/43.jpg)
Summary
Example-based methods are very similar.
Minor variations by target audience.
Skills are transferable.
![Page 44: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/44.jpg)
Nomenclature
Check
Example
Specification
Test
![Page 46: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/46.jpg)
Backup
![Page 47: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/47.jpg)
![Page 48: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/48.jpg)
![Page 49: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/49.jpg)
![Page 50: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/50.jpg)
Drive out traceability
-
-
-
![Page 51: Growing software from examples](https://reader035.fdocuments.in/reader035/viewer/2022070416/56815128550346895dbf4742/html5/thumbnails/51.jpg)
Verify dependencies
-
-
-