Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

ITB2015 - Behavior Driven Development, Automation and Continuous Integration

548 vues

Publié le

In this session we will explore the semantics and theory behind Behavior Driven Development and how it can unify a team with its ubiquitous language. We will then go in a tour of TestBox for applying BDD/TDD into our CFML applications. Our tour will end with setting up a Jenkins Continous Integration Server and building scripts for automated testing and reporting.

Publié dans : Technologie
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

ITB2015 - Behavior Driven Development, Automation and Continuous Integration

  1. 1. Intro  to  TDD  &  BDD
 Test Driven Development 
 & Behaviour Driven Development Kev McCabe In to The Box 2015 Sunday, 19 April 15
  2. 2. Who am I? • Kev McCabe AKA @bigmadkev • Freelance Code Smith 
 & Agile Coach • Developer for over 18 years • Worked in TV Broadcast, Healthcare, Travel & Finance • Adobe Community Professional
  3. 3. Agenda • Types of testing • Why Test • TDD Intro • BDD Intro • TestBox BDD
  4. 4. Types of Testing GUI Integration Unit Tests Exploratory testing
  5. 5. Real World Testing Pyramid GUI Integration Exploratory testing Unit TestsManual Testing
  6. 6. Bugs cost money ^ Kaner,Cem; JamesBach, Bret Pettichord (2001). Lessons Learned inSoftwareTesting: A Context-Driven Approach.Wiley. p. 4. ISBN 0-471-08112-4.
  7. 7. One Big Lie!
  8. 8. What is TDD Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards
  9. 9. What is TDD What it is • A tool to drive design • Developer focused • Works with BDD • Non-intuitive but powerful tool What it is not • About testing • For the faint hearted • A silver bullet • Easy
  10. 10. TDD Process From  Growing  Object-­‐Oriented  Software  by  Nat  Pryce  and  Steve  Freeman
  11. 11. What is BDD In software engineering, behavior-driven development (BDD) is a software development process that emerged from test-driven development (TDD).Behavior- driven development combines the general techniques and principles of TDD with ideas from domain-driven design and object-oriented analysis and design to provide software developers and business analysts with shared tools and a shared process to collaborate on software development, with the aim of delivering “software that matters”
  12. 12. What is BDD • Dan North - http://dannorth.net/introducing-bdd • Ubiquitous language – existing or being everywhere at the same time : constantly • Promotes communication & collaboration between – Developers + business analysts + stakeholders • Focuses on stories or requirements rather than on functions • Focuses on what a system should do and not on how it should be implemented – Better readability and visibility – Verify that software works but also that it meets customer expectations
  13. 13. BDD Process Story Generate Scenarios Pass Scenarios
  14. 14. Generating Scenarios
  15. 15. As an Insurance Company, I want to generate life insurance risk so that we don’t lose money Example 3 Amigos Session
  16. 16. In order to not lose money as an insurance company, I want to generate life insurance risk Example 3 Amigos Session
  17. 17. Scenario One Given a customer When they request a quote Then we return an insurance risk
  18. 18. BDD User stories & acceptance criteria Domain Learning Examples Examples Examples Examples Examples Open Questions New Stories
  19. 19. Scenario One Given a customer under 30 years When they request a life insurance quote Then we return an insurance risk of low
  20. 20. Given a customer under 55 years When they request a life insurance quote Then we return an insurance risk of med Scenario Two
  21. 21. Given a customer over 55 years When they request a life insurance quote Then we return an insurance risk of high Scenario Three
  22. 22. Given a customer between 
 <lowerLimit> & <upperLimit> When they request a life insurance quote Then we return an insurance risk of <riskResult> |lowerLimit|upperLimit|riskResult| |18 | 29 | low | |30 | 54 | med | |55 | 65 | high | Scenario Outline
  23. 23. What if they smoke? What if they drink alcohol? What if they have known health issues? What about people under 18 and over 70? Questions Raised
  24. 24. In order not to insurance under & over aged customers as an insurance company, I want to raise an exception Additional Stories
  25. 25. We have learnt about our domain The customer worries about age limits more than anything else We also know that other items are upcoming but …… we don’t need to develop them until we have that story! What we have learnt
  26. 26. Having conversations Is more important than
 capturing conversations Is more important than
 automating conversations www.slideshare.net/lunivore/behavior-­‐driven-­‐development-­‐11754474   Liz  Keogh  @lunivore
  27. 27. describe(“Customer is between 18 & 29”, function() {   it( “will return an insurance risk of low”, function() {   var customer = new customerBuilder().withAge(24).build();   expect(riskService.generateRiskRating(customer))
 .toBe(“low”);   })   })   describe(“Customer is between 30 & 54”, function() {   it( “will return an insurance risk of med”, function() {   var customer = new customerBuilder().withAge(37).build(); expect(riskService.generateRiskRating(customer))
 .toBe(“med”);   })   }) Scenario to TestBox
  28. 28. BDD & TDD From  Growing  Object-­‐Oriented  Software  by  Nat  Pryce  and  Steve  Freeman
  29. 29. TestBox is a next generation testing framework for ColdFusion that is based on BDD (Behavior Driven Development) for providing a clean obvious syntax for writing tests. It contains not only a testing framework, runner, assertions and expectations library but also integrates with MockBox for mocking and stubbing. It also supports xUnit style of testing and MXUnit compatibilities.
  30. 30. What you get!
  31. 31. Test Harness
  32. 32. Test Bundle CFC • No matter what style, you start with a test bundle CFC • Inherits from testbox.system.BaseSpec or not!
 • URL runner caveat • Get’s lots of methods and properties for testing • TestBox will then execute all tests within 1 or more bundles
  33. 33. Running your bundles • Execute bundle (if using inheritance) via the URL – http://mysite/test/bundle.cfc?method=runRemote • Using the TestBox Class: testbox.system.TestBox – Bundle(s) Runner – Directory Runner – SOAP Runner – HTTP/REST Runner – ANT Runner – Custom Runners • What’s the output? We call this reporters
  34. 34. Reporters • ANTJunit : A specific variant of JUnit XML that works with the ANT junitreport task • Codexwiki : Produces MediaWiki syntax for usage in Codex Wiki • Console : Sends report to console • Doc : Builds semantic HTML to produce nice documentation • Dot : Builds an awesome dot report • JSON : Builds a report into JSON • JUnit : Builds a JUnit compliant report • Raw : Returns the raw structure representation of the testing results • Simple : A basic HTML reporter • Text : Back to the 80's with an awesome text report • XML : Builds yet another XML testing report • Tap : A test anything protocol reporter • Min : A minimalistic view of your test reports
  35. 35. Let’s walk through an example • The life insurance example • We’ll use a BDD Spec to tell us when we’re done • We’ll use TDD to drive the design of our code
  36. 36. What the future holds! • Grunt JS Tasks • NodeJS Runners and Watchers • Sublime Runner • More Reporters • More focus on automation • Gherkins support