Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

The key to move really fast – Lightning Talk | Niclas Nilsson | LTG-43/DTG-7

351 views

Published on

Presentation hållen vid samarrangemanget Lean Tribe Gathering 43 och Dev Tribe Gathering 7 i Göteborg 9 maj 2017.

Published in: Software
  • Be the first to comment

  • Be the first to like this

The key to move really fast – Lightning Talk | Niclas Nilsson | LTG-43/DTG-7

  1. 1. The key to move really fast
  2. 2. Niclas Nilsson
  3. 3. Jon-Erling Dahl
  4. 4. Coaching and consulting
  5. 5. Automates your paperwork
  6. 6. The new reality
  7. 7. Release more often
  8. 8. Solution: Test automation
  9. 9. Automation of System Tests
  10. 10. "We have unit tests with good coverage."
  11. 11. Acceptance Tests > Unit Tests
  12. 12. 2 unit tests 0 acceptance tests
  13. 13. We need automated acceptance tests
  14. 14. BDD Behaviour Driven Development
  15. 15. ATDD Acceptance-Test Driven Development
  16. 16. Communicate through stories
  17. 17. ATM example Feature: Cash withdrawal In order to get money when the bank is closed As an Account Holder I want to withdraw cash from an ATM Scenario: Account has sufficient funds Given the account balance is 100 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should dispense 20
  18. 18. Not just happy cases Scenario: Account has insufficient funds Given the account balance is 10 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should not dispense any money And the ATM should say there are insufficient funds And the account balance should be 10 And the card should be returned Scenario: Card has been disabled Given the card is disabled When the account holder requests 20 Then the ATM should retain the card
  19. 19. Stories All in plain text Works well on paper If only we could execute it...
  20. 20. Cucumber
  21. 21. http://cukes.info “Cucumber is a tool for running automated tests written in plain language”
  22. 22. Features in plain text Feature: Cash withdrawal In order to get money when the bank is closed As an Account Holder I want to withdraw cash from an ATM Scenario: Account has sufficient funds Given the account balance is 100 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should dispense 20
  23. 23. Not just happy cases Scenario: Account has insufficient funds Given the account balance is 10 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should not dispense any money And the ATM should say there are insufficient funds And the account balance should be 10 And the card should be returned Scenario: Card has been disabled Given the card is disabled When the account holder requests 20 Then the ATM should retain the card
  24. 24. Features in plain text Feature: Cash withdrawal In order to get money when the bank is closed As an Account Holder I want to withdraw cash from an ATM Scenario: Account has sufficient funds Given the account balance is 100 And the card is valid And the machine contains enough money When the account holder requests 20 Then the ATM should dispense 20
  25. 25. Steps in any programming language
  26. 26. Cucumber Specflow Behat ...and many more
  27. 27. Unit tests Covers smaller units/components Fast execution times Very technical Good for complex algorithms Good for reusable components
  28. 28. Acceptance tests Covers slices of the complete system Slower execution times Intentional Good for the complete system Good for avoiding complex/subtle integration bugs Provides a holistic safety net
  29. 29. Test through the browser
  30. 30. Hit the database
  31. 31. Only mock external systems
  32. 32. "But that's so slow..."
  33. 33. True. But the value is much higher.
  34. 34. "But it's quite hard..."
  35. 35. At first. But it gets quite easy after the initial efforts.
  36. 36. "But it takes more time..."
  37. 37. True. At first. But after a short while, you get much faster.
  38. 38. And by the way: You can actually have the cookie and eat it too.
  39. 39. How to have the cookie and eat it too: The feature specs should always hold. But you can have multiple sets of step definitions - Full scale, including UI and DB - Lighter and faster, no UI, no DB Note: The same feature specs - different step impls!
  40. 40. Unit tests cannot replace acceptance tests
  41. 41. but...
  42. 42. Acceptance tests can replace unit tests
  43. 43. Most good systems have both
  44. 44. Avoid record/replay Often very brittle
  45. 45. Craft them well.
  46. 46. And remember...
  47. 47. Acceptance Tests > Unit Tests
  48. 48. Niclas Nilsson niclas@fooheads.com @niclasnilsson
  49. 49. We help you get started

×