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

Doodle-Driven Development - Ciaran McNulty

Avatar for Cucumber Cucumber
April 04, 2019
87

Doodle-Driven Development - Ciaran McNulty

Avatar for Cucumber

Cucumber

April 04, 2019
Tweet

More Decks by Cucumber

Transcript

  1. Scenario: Present for full amount Given I have a pending

    transaction for £100 When a presentment for £100 is received Then I should have a completed transaction for £100 Scenario: Present for less than full amount Given I have a pending transaction for £100 When a presentment for £50 is received Then I should have a completed transaction for £50 And I should have a pending transaction for £50 @ciaranmcnulty | [email protected] | #cukenfest
  2. Effective discovery with drawings · Create the conditions where it

    can happen · Pick the right formats · Don't force it @ciaranmcnulty | [email protected] | #cukenfest
  3. Gherkin is great: 1. Looks like the conversation 2. Trackable

    in VCS 3. Parseable by machines @ciaranmcnulty | [email protected] | #cukenfest
  4. Graphviz digraph { "No transactions" -> "Pending £100" [label="£100 Authorisation"];

    "Pending £100" -> "Completed £110" [label="£110 Presentment"]; "Pending £100" -> "Completed £50 \n Pending £50" [label="£50 Presentment"]; "Completed £50 \n Pending £50" -> "Completed £50 \n Completed £50" [label="£50 Presentment"]; "Pending £100" -> "Completed £100" [label="£100 Presentment"]; "Completed £100" -> "Completed £100 \n Completed £100" [label="£100 Presentment"]; } @ciaranmcnulty | [email protected] | #cukenfest
  5. Effective formulation · Find a format that is 'close enough'

    · Try and forget the tools during discovery · Sync based on mtime @ciaranmcnulty | [email protected] | #cukenfest
  6. digraph { "No transactions" -> "Pending £100" [label="£100 Authorisation"]; "Pending

    £100" -> "Completed £110" [label="£110 Presentment"]; "Pending £100" -> "Completed £50 \n Pending £50" [label="£50 Presentment"]; "Completed £50 \n Pending £50" -> "Completed £50 \n Completed £50" [label="£50 Presentment"]; "Pending £100" -> "Completed £100" [label="£100 Presentment"]; "Completed £100" -> "Completed £100 \n Completed £100" [label="£100 Presentment"]; } @ciaranmcnulty | [email protected] | #cukenfest
  7. foreach (file('/presentment.dot') as $line) { if (!preg_match('/->/', $line)) { continue;

    } $pattern = '/"(?<start>.*)".*->.*"(?<end>.*)".*label="(?<transition>.*?)"/'; if (!preg_match($pattern, $line, $matches)) { throw new Exception ("Cannot parse line:\n$line"); } $this->setUp($matches['start']); $this->applyEvent($matches['end']); $this->assertEndState($matches['transition']); } @ciaranmcnulty | [email protected] | #cukenfest
  8. Effective automation · Cheat the format · Do the easiest

    thing that works · Write brittle tests @ciaranmcnulty | [email protected] | #cukenfest
  9. ! Do more drawing ! Find machine formats ! Write

    scrappy tests @ciaranmcnulty | [email protected] | #cukenfest