Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Confidently Insured

Confidently Insured

Insurance is a confusing (mine-) field where terms and policies mean something entirely different from terms and policies. To remain confident we have to adapt our behaviour and let our test suite do the work for us.

Using DDD, BDD and TDD we will discover, design and implement this risky business with one goal in mind: Test Driven To Do's! Let the system tell you what to do next. TDTD will keep your pace steady, energy up and stress down.

Quite a claim? Relax, TDTD has you covered!

pelshoff

June 27, 2022
Tweet

More Decks by pelshoff

Other Decks in Programming

Transcript

  1. @pelshoff
    Welcome
    Confidently Insured

    View Slide

  2. @pelshoff
    @pelshoff
    Today
    ● Insurance premiums are fun
    ● BDD * DDD * TDD => TDTD (or TDETDSFMC)
    ● Run the tests
    ● Solo? Pair? Mob?
    Photo by Blake Weyland on Unsplash

    View Slide

  3. @pelshoff
    @pelshoff
    Today
    1. A testing refresher
    2. A vicious debate on testing habits
    3. An intro into insurance premiums
    4. Writing some scenarios together, or skip to…
    5. Going at it in groups, pairs or solo
    6. Reflect on the content and the form
    Photo by Blake Weyland on Unsplash

    View Slide

  4. @pelshoff
    @pelshoff
    You will need
    ● An editor (PHPStorm, VSCode, …) (duh)
    ● A unit testing framework (PHPUnit, NUnit, …)
    ● A behaviour testing framework (Behat, Specflow, …)
    ● Pen, paper, postits… Miro?
    ● Excel?
    ● Curiosity
    ● The confidence will come :-P
    Photo by Blake Weyland on Unsplash

    View Slide

  5. @pelshoff
    1. Testing
    The wrong(?) word for the right(?) practice

    View Slide

  6. @pelshoff
    1. Testing Specifying
    The right(?) word for the right(?) practice

    View Slide

  7. @pelshoff
    @pelshoff
    Confidence
    “Testing is all about confidence.
    When I'm working, I need to be
    confident that I haven't broken
    anything, and that the code that I
    just wrote works as expected. When
    I'm working, that's ALL I need to test
    for.” – Alan Holub
    https://twitter.com/allenholub/status/1538561251868954624
    Photo by Daniel Mingook Kim on Unsplash

    View Slide

  8. @pelshoff
    @pelshoff
    Test automation benefits
    Module life cycle
    Having Changing
    Building
    Spiking /
    Designing
    Debugging
    Delivering Deleting..?

    View Slide

  9. @pelshoff
    @pelshoff
    Test automation drawbacks
    Module life cycle
    It’s quite hard It’s quite hard
    It’s quite hard
    It’s quite hard It’s quite hard
    It’s quite hard It’s quite hard

    View Slide

  10. @pelshoff
    @pelshoff
    Test automation benefits
    Module life cycle
    Having Changing
    Building
    Spiking /
    Designing
    Debugging
    Delivering Deleting..?

    View Slide

  11. @pelshoff
    Feature
    Integration
    Unit
    E2E, browser, approval, manual, etc.

    View Slide

  12. @pelshoff
    The challenge
    Hide details in a lower
    layer of testing

    View Slide

  13. @pelshoff
    Feature
    Integration
    Unit

    View Slide

  14. @pelshoff
    @pelshoff
    /tests/features/FeatureTesting/testingOneSingle.feature
    Feature: writing scenarios
    In order to have working software that does what I need
    As a customer of a software dev team
    I want to write almost-natural-language executable specs
    Scenario: Running a pending scenario
    Given an editor that allows me to create flat files
    And a tool that can run features
    When I create a feature file
    And I run the scenario
    Then I get a pending result
    Scenario: Running a scenario that was not yet implemented
    Given an editor that allows me to create flat files
    And a tool that can run features
    And I create a feature file
    When I add context
    And I run the scenario
    Then I get a failed result

    View Slide

  15. @pelshoff
    Feature
    Integration
    Unit

    View Slide

  16. @pelshoff
    App+Domain+Infra
    Domain
    Domain internals

    View Slide

  17. @pelshoff
    2. Habits
    Who knows where the word “habit” comes from?

    View Slide

  18. @pelshoff
    @pelshoff
    Saint Anthony of Padua Taking the Habit of the Franciscan Order | 37.547 | The Walters Art Museum

    View Slide

  19. @pelshoff
    Test-Driven Todo
    Today’s habit

    View Slide

  20. @pelshoff
    3. Insurance
    What is it?

    View Slide

  21. @pelshoff
    @pelshoff
    Policy lifecycle
    Policy
    Term Term Term
    V1 V1 V2 V1
    Renewal
    Adjustment
    Lapse

    View Slide

  22. @pelshoff
    @pelshoff
    Case: Premium
    “Yes Hello I would like one insurance please”
    “That’ll be £365”

    View Slide

  23. @pelshoff
    @pelshoff
    Case: Premium
    Rating engine Broker platform/Manual Renewal
    Quote
    Policy
    Invoice
    Premium might be
    prorated
    Remember commission
    and IPT
    One for full term, or one
    per month

    View Slide

  24. @pelshoff
    @pelshoff
    The Goal
    Build a system that can generate invoices for policies
    ● Capture policy life cycle, generate invoices
    ● Correct info is paramount - mistakes can cost us our license
    ● Please don’t markup an invoice, we’ll use an external service provider
    ● Please don’t build a rating engine, assume the cover is rated
    ● In fact: focus, assume YAGNI, ask “is it ok if we leave X out?”

    View Slide

  25. @pelshoff
    4. Scenarios
    As a User
    I want to pay for my insurance
    So that my insurance is paid for

    View Slide

  26. @pelshoff
    Feature
    “Normalized”

    View Slide

  27. @pelshoff
    Scenario
    Scenario “Denormalized”

    View Slide

  28. @pelshoff
    @pelshoff
    /tests/features/FeatureTesting/eventsAreCaptured.feature
    Feature: capturing events
    In order to map my understanding of the domain
    As a dev team
    I want to turn an event storm into an executable spec
    Scenario: Outcome pertaining to C
    Given event A has happened
    And event B has happened
    When the circumstances will lead to C
    And the command that triggers C or D fires
    Then event C has happened (with details X, Y & Z)
    Scenario: Outcome pertaining to E
    Given event A has happened
    And event B has happened
    When the circumstances will lead to D
    And the command that triggers C or D fires
    Then event D has happened
    And event E has happened (with details X, Y & Z)

    View Slide

  29. @pelshoff
    @pelshoff
    Wall of text
    When a customer wants insurance, we quote them for their situation and their desired cover.
    If we can offer the cover ourselves, our rating engine determines the premium. If we place the risk through a broker
    platform or one of the insurers we have good connections with, we get the premium from them.
    When the customer accepts the quote we bind the policy and, from the effective date on, the customer will be on cover.
    We send them an invoice for the full term, unless they want to pay per month.
    At the end of the term the policy may be renewed. By default the new term will have the same premium as the previous
    term. Sometimes a customer wants to adjust their policy mid-term. In that case we quote them for their updated situation
    and if they accept we continue the term with the new version and the customer gets an invoice for the adjustment.
    If the customer does not want to renew their policy, we mark the policy as lapsed.
    In some situations we allow the customer to cancel their policy. In that case they get the premium for the cancelled time
    back.

    View Slide

  30. @pelshoff
    5. The Actual Work
    The rest is just overhead, amirite?

    View Slide

  31. @pelshoff
    @pelshoff
    Todo
    Build a system that can generate invoices for policies
    ● Capture policy life cycle, generate invoices
    ● Correct info is paramount - mistakes can cost us our license
    ● Please don’t markup an invoice, we’ll use an external service provider
    ● Please don’t build a rating engine, assume the cover is rated
    ● In fact: focus, assume YAGNI, ask “is it ok if we leave X out?”

    View Slide

  32. @pelshoff
    6. Re ecting

    View Slide

  33. @pelshoff
    Pim Elshoff
    twitter.com/pelshoff
    [email protected]
    Confidently insured

    View Slide