SlideShare una empresa de Scribd logo
1 de 42
Descargar para leer sin conexión
Les Tests avec Ruby on Rails
Jean-Michel Garnier <jean-michel arobase 21croissants point com>
         Paris On Rails – 10 Décembre 2007
Plan de la présentation

    Background
●


        De 1975 ... à nos jours
    –

    Théorie
●


        RSpec par l'exemple
    –

        Design, Spécifications, Documentation
    –

    Pratique
●


        Outils: Autotest, rcov, CruiseControl.rb
    –

        RSpec on Rails, Selenium
    –


                                                                                              2
         Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Background
Qui est-ce?
FRED BROOKS
                        1975:
      “The Mythical Man-Month”
          ¼    Spécificier
      ●



          1/6 Programmer
      ●



          ½    Tests
      ●



                         1986:
          “No Silver Bullet”
      Modèle en V =
      Vers le Modèle Itératif
      http://www.cs.unc.edu/~brooks/
Qui est-ce?
KENT BECK
                                      1994:
                            “Simple Smalltalk Testing”
                        ●



                        Framework pour automatiser
                          les tests unitaires


                                      2002:
                        “Test Driven Development”
                        Ecrire les tests avant le code


http://www.threeriversinstitute.org/Kent%20Beck.htm
Qui est-ce?
MARTIN FOWLER

                  2000:
          “Refactoring”
      ●


          article sur l'Intégration
      ●

          Continue
      http://www.martinfowler.com
L'équipe de RSpec

                                          Début 2004 : BDD
                                      ●


                                          Août 2005: RSpec 0.1
                                      ●


                                          Mai 2007: RSpec 1.0
                                      ●


                                          30 250 downloads
                                      ●
Aslak Hellesøy (NO) David Chelimsky
                                          (nº27) RubyForge
                    (US)

                                          40 contributeurs
                                      ●




                      + Brian Takita Dave Astels
                        Steve Baker Luke Redpath
Dan North (UK)
Livres pour 2008
Théorie
Anatomie d'une spécification
Comportement (contexte)




                                                 Exemple


                                             Exemple
should I stay or should I go?

RSpec ajoute 2 méthodes à la class 'Object': should et
 should_not




Avec Test::Unit :




             Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Langage naturel (en VO)
ruby spec/project_spec.rb
Résultat




Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Customizer Rspec



          Pas très lisible!
Solution: écrire son propre “Matcher”
http://martinfowler.com/articles/mocksArentStubs.html




       Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Tests = Design

    TDD = On ne code que l'indispensable!
●



    Le Refactoring (Améliorer le code) ne provoque pas de
●

    regressions
    Utilisation de “mocks objects” pour définir l'API
●



    Le code de qualité est facile à tester
●




               Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Tests = Spécifications
Tests = Documentation


                                                 Exemples exécutable =
                                            ●

                                                 Documentation toujours á
                                                 jour
                                                 Plus besoin de rdoc ;-)
                                            ●




 Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Pratique
Démarrage

    Peep Code: RSpec (in english)
●



    IDE: RSpec intégré avec:
●




    Installer les plugins rspec et rspec_on_rails
●



    rake spec:generate
●




               Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Autotest

    Problème: les specs s'executent pendant 10 min...
●



    Solution: Autotest n'execute que les specs nécessaires
●



Notifications visuelles (plugins Growl, Notify,...) et sonores



    Intégré avec
●




    http://ph7spot.com/articles/getting_started_with_autotest
                Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Garantir la couverture avec
                     rcov
    sudo gem install rcov
●



    rake spec:rcov
●




                          http://eigenclass.org/hiki.rb?rcov
                Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Couverture détaillée
Intégration Continue


                                            http://cruisecontrolrb.thoughtworks.com




                                          cruise add <name> -u <url>
                                          cruise start
                                         Le lapin il est ROUGE?
                                         Le Build il est cassé!
                                            http://nabaztag.rubyforge.org/


Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
CruiseControl.rb
Exemple de spec/models




http://edgerepo.com/svn/opensource/ruby/plugins/rspec_expectation_matchers/
spec/models (méthodes Métier)




    Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
spec/models (Finders)




Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
specs/fixtures

    Quelque problèmes: associations, lisibilité
●



    Mais ça s'améliore dans Rails 2.0 (un peu)
●



    Alternatives:
●


        Fixture scenarios: http://errtheblog.com/post/7708
    –

        Tests exemplars:
    –

         http://evang.eli.st/blog/2007/8/8/doin-the-fixtures-plugin-thing




                  Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Exemple de spec/controllers
Autres “matchers“




Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Spécifier les Vues?

                                         Problème:
                                         Les vues changent
                                         tout le temps !




Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Exemple de spec/views




 Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Selenium

    Tests d'intégration + automatiser les tests d'acceptation
●

    des utilisateurs
     Vérifier si l'application fonctionne avec tous les
●

    butineurs du marché
    Compatible avec:
●




               Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Selenium – le film




Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
Selenium specs




90% de la spec GENERE AVEC SELENIUM-IDE !!!
Merci de votre attention!

       Questions - Réponses




                                                                                     42
Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.

Más contenido relacionado

Destacado

Tarea 8 uso video_carmen indira velez
Tarea 8 uso video_carmen indira velezTarea 8 uso video_carmen indira velez
Tarea 8 uso video_carmen indira velez
carivfi
 
French Trip
French TripFrench Trip
French Trip
mrverney
 
Le Petit Chaperon Rouge
Le Petit Chaperon RougeLe Petit Chaperon Rouge
Le Petit Chaperon Rouge
guest5c0510
 
Parfaits
ParfaitsParfaits
Parfaits
charbu2
 
Village Eco Prg Du 17 DéC08 Vs Finale
Village Eco Prg Du 17 DéC08 Vs FinaleVillage Eco Prg Du 17 DéC08 Vs Finale
Village Eco Prg Du 17 DéC08 Vs Finale
Afet
 
S Curit Routi Re
S Curit Routi ReS Curit Routi Re
S Curit Routi Re
guestf344b8
 

Destacado (20)

Bejal
BejalBejal
Bejal
 
Tarea 8 uso video_carmen indira velez
Tarea 8 uso video_carmen indira velezTarea 8 uso video_carmen indira velez
Tarea 8 uso video_carmen indira velez
 
French Trip
French TripFrench Trip
French Trip
 
Le visage est l’image de l’âme
Le visage est l’image de l’âmeLe visage est l’image de l’âme
Le visage est l’image de l’âme
 
Petite SoiréE Chez Max2
Petite SoiréE Chez Max2Petite SoiréE Chez Max2
Petite SoiréE Chez Max2
 
Nettoyeur
NettoyeurNettoyeur
Nettoyeur
 
PréSentation2
PréSentation2PréSentation2
PréSentation2
 
Le Petit Chaperon Rouge
Le Petit Chaperon RougeLe Petit Chaperon Rouge
Le Petit Chaperon Rouge
 
Pda Inoxia Janvier 08
Pda Inoxia Janvier 08Pda Inoxia Janvier 08
Pda Inoxia Janvier 08
 
Couleursdumonde
CouleursdumondeCouleursdumonde
Couleursdumonde
 
Jewishgen, El Hogar de la Genealogía Judía
Jewishgen, El Hogar de la Genealogía JudíaJewishgen, El Hogar de la Genealogía Judía
Jewishgen, El Hogar de la Genealogía Judía
 
Alex C Publicite
Alex C PubliciteAlex C Publicite
Alex C Publicite
 
Parfaits
ParfaitsParfaits
Parfaits
 
Arxtech Mobilier Tactile Interactif
Arxtech Mobilier Tactile InteractifArxtech Mobilier Tactile Interactif
Arxtech Mobilier Tactile Interactif
 
Clase 4 graficos
Clase 4 graficosClase 4 graficos
Clase 4 graficos
 
Citations de spiritualite (6)
Citations de spiritualite (6)Citations de spiritualite (6)
Citations de spiritualite (6)
 
Leparachute Tr Sbeautexte 1
Leparachute Tr Sbeautexte 1Leparachute Tr Sbeautexte 1
Leparachute Tr Sbeautexte 1
 
Village Eco Prg Du 17 DéC08 Vs Finale
Village Eco Prg Du 17 DéC08 Vs FinaleVillage Eco Prg Du 17 DéC08 Vs Finale
Village Eco Prg Du 17 DéC08 Vs Finale
 
S Curit Routi Re
S Curit Routi ReS Curit Routi Re
S Curit Routi Re
 
Tribus De L Omo
Tribus De L OmoTribus De L Omo
Tribus De L Omo
 

Similar a Les Tests avec Ruby on Rails et RSpec (in French)

Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422
journeyer
 
Rails Conf Europe 2007 Notes
Rails Conf  Europe 2007  NotesRails Conf  Europe 2007  Notes
Rails Conf Europe 2007 Notes
Ross Lawley
 
So gelingt der Umstieg von PHP4 auf PHP5: Erneuerung von Geschäftsanwendung...
So gelingt der Umstieg von PHP4 auf  PHP5: Erneuerung von  Geschäftsanwendung...So gelingt der Umstieg von PHP4 auf  PHP5: Erneuerung von  Geschäftsanwendung...
So gelingt der Umstieg von PHP4 auf PHP5: Erneuerung von Geschäftsanwendung...
Lars Jankowfsky
 

Similar a Les Tests avec Ruby on Rails et RSpec (in French) (20)

Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Why Architecture in Web Development matters
Why Architecture in Web Development mattersWhy Architecture in Web Development matters
Why Architecture in Web Development matters
 
Starting a new ruby on rails development
Starting a new ruby on rails developmentStarting a new ruby on rails development
Starting a new ruby on rails development
 
Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422
 
Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...
Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...
Peer Code Review: In a Nutshell and The Tantric Team: Getting Your Automated ...
 
Scaling a Rails Application from the Bottom Up
Scaling a Rails Application from the Bottom Up Scaling a Rails Application from the Bottom Up
Scaling a Rails Application from the Bottom Up
 
Crate - ruby based standalone executables
Crate - ruby based standalone executablesCrate - ruby based standalone executables
Crate - ruby based standalone executables
 
Kamaelia - Networking Using Generators
Kamaelia - Networking Using GeneratorsKamaelia - Networking Using Generators
Kamaelia - Networking Using Generators
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Deploying And Monitoring Rails
Deploying And Monitoring RailsDeploying And Monitoring Rails
Deploying And Monitoring Rails
 
nanoHUB.org: Cyberinfrastructure for Research and Education
nanoHUB.org: Cyberinfrastructure for Research and EducationnanoHUB.org: Cyberinfrastructure for Research and Education
nanoHUB.org: Cyberinfrastructure for Research and Education
 
Quick and Solid - Baremetal on OpenStack | Rico Lin
Quick and Solid - Baremetal on OpenStack | Rico LinQuick and Solid - Baremetal on OpenStack | Rico Lin
Quick and Solid - Baremetal on OpenStack | Rico Lin
 
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
 
Rails Conf Europe 2007 Notes
Rails Conf  Europe 2007  NotesRails Conf  Europe 2007  Notes
Rails Conf Europe 2007 Notes
 
Amoocon May 2009 Germany
Amoocon May 2009   GermanyAmoocon May 2009   Germany
Amoocon May 2009 Germany
 
InterCon - Ruby e Rails
InterCon - Ruby e RailsInterCon - Ruby e Rails
InterCon - Ruby e Rails
 
Till Vollmer Presentation
Till Vollmer PresentationTill Vollmer Presentation
Till Vollmer Presentation
 
Katello on TorqueBox
Katello on TorqueBoxKatello on TorqueBox
Katello on TorqueBox
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
 
So gelingt der Umstieg von PHP4 auf PHP5: Erneuerung von Geschäftsanwendung...
So gelingt der Umstieg von PHP4 auf  PHP5: Erneuerung von  Geschäftsanwendung...So gelingt der Umstieg von PHP4 auf  PHP5: Erneuerung von  Geschäftsanwendung...
So gelingt der Umstieg von PHP4 auf PHP5: Erneuerung von Geschäftsanwendung...
 

Más de Jean-Michel Garnier

Spécification par l'exemple & Tests d'Acceptance Agile avec cucumber
Spécification par l'exemple & Tests d'Acceptance Agile  avec cucumberSpécification par l'exemple & Tests d'Acceptance Agile  avec cucumber
Spécification par l'exemple & Tests d'Acceptance Agile avec cucumber
Jean-Michel Garnier
 
Intro a RSpec, BDD, webapps User Acceptance Testing
Intro a RSpec, BDD, webapps User Acceptance TestingIntro a RSpec, BDD, webapps User Acceptance Testing
Intro a RSpec, BDD, webapps User Acceptance Testing
Jean-Michel Garnier
 

Más de Jean-Michel Garnier (11)

2015 07 08_genevarb_maniok_presentation
2015 07 08_genevarb_maniok_presentation2015 07 08_genevarb_maniok_presentation
2015 07 08_genevarb_maniok_presentation
 
Tdd cara nov2010
Tdd cara nov2010Tdd cara nov2010
Tdd cara nov2010
 
Spécification par l'exemple & Tests d'Acceptance Agile avec cucumber
Spécification par l'exemple & Tests d'Acceptance Agile  avec cucumberSpécification par l'exemple & Tests d'Acceptance Agile  avec cucumber
Spécification par l'exemple & Tests d'Acceptance Agile avec cucumber
 
Cucumber Ecosystem Presentation
Cucumber Ecosystem PresentationCucumber Ecosystem Presentation
Cucumber Ecosystem Presentation
 
Tests d'Acceptance utilisateur avec cucumber
Tests d'Acceptance utilisateur avec cucumberTests d'Acceptance utilisateur avec cucumber
Tests d'Acceptance utilisateur avec cucumber
 
Tests Interfaces Web avec Rails
Tests Interfaces Web avec RailsTests Interfaces Web avec Rails
Tests Interfaces Web avec Rails
 
Fast web acceptance testing with selenium-grid
Fast web acceptance testing with selenium-gridFast web acceptance testing with selenium-grid
Fast web acceptance testing with selenium-grid
 
User Acceptance Testing Driven by Humans telling Stories (with RSpec)
User Acceptance Testing Driven by Humans telling Stories (with RSpec)User Acceptance Testing Driven by Humans telling Stories (with RSpec)
User Acceptance Testing Driven by Humans telling Stories (with RSpec)
 
Intro a RSpec, BDD, webapps User Acceptance Testing
Intro a RSpec, BDD, webapps User Acceptance TestingIntro a RSpec, BDD, webapps User Acceptance Testing
Intro a RSpec, BDD, webapps User Acceptance Testing
 
Global Warming Lifestyle Change
Global Warming Lifestyle ChangeGlobal Warming Lifestyle Change
Global Warming Lifestyle Change
 
Testing Ruby on Rails (spanish)
Testing Ruby on Rails (spanish)Testing Ruby on Rails (spanish)
Testing Ruby on Rails (spanish)
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Les Tests avec Ruby on Rails et RSpec (in French)

  • 1. Les Tests avec Ruby on Rails Jean-Michel Garnier <jean-michel arobase 21croissants point com> Paris On Rails – 10 Décembre 2007
  • 2. Plan de la présentation Background ● De 1975 ... à nos jours – Théorie ● RSpec par l'exemple – Design, Spécifications, Documentation – Pratique ● Outils: Autotest, rcov, CruiseControl.rb – RSpec on Rails, Selenium – 2 Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 4.
  • 6. FRED BROOKS 1975: “The Mythical Man-Month” ¼ Spécificier ● 1/6 Programmer ● ½ Tests ● 1986: “No Silver Bullet” Modèle en V = Vers le Modèle Itératif http://www.cs.unc.edu/~brooks/
  • 8. KENT BECK 1994: “Simple Smalltalk Testing” ● Framework pour automatiser les tests unitaires 2002: “Test Driven Development” Ecrire les tests avant le code http://www.threeriversinstitute.org/Kent%20Beck.htm
  • 10. MARTIN FOWLER 2000: “Refactoring” ● article sur l'Intégration ● Continue http://www.martinfowler.com
  • 11. L'équipe de RSpec Début 2004 : BDD ● Août 2005: RSpec 0.1 ● Mai 2007: RSpec 1.0 ● 30 250 downloads ● Aslak Hellesøy (NO) David Chelimsky (nº27) RubyForge (US) 40 contributeurs ● + Brian Takita Dave Astels Steve Baker Luke Redpath Dan North (UK)
  • 14. Anatomie d'une spécification Comportement (contexte) Exemple Exemple
  • 15. should I stay or should I go? RSpec ajoute 2 méthodes à la class 'Object': should et should_not Avec Test::Unit : Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 18. Résultat Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 19. Customizer Rspec Pas très lisible! Solution: écrire son propre “Matcher”
  • 20. http://martinfowler.com/articles/mocksArentStubs.html Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 21. Tests = Design TDD = On ne code que l'indispensable! ● Le Refactoring (Améliorer le code) ne provoque pas de ● regressions Utilisation de “mocks objects” pour définir l'API ● Le code de qualité est facile à tester ● Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 23. Tests = Documentation Exemples exécutable = ● Documentation toujours á jour Plus besoin de rdoc ;-) ● Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 25. Démarrage Peep Code: RSpec (in english) ● IDE: RSpec intégré avec: ● Installer les plugins rspec et rspec_on_rails ● rake spec:generate ● Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 26. Autotest Problème: les specs s'executent pendant 10 min... ● Solution: Autotest n'execute que les specs nécessaires ● Notifications visuelles (plugins Growl, Notify,...) et sonores Intégré avec ● http://ph7spot.com/articles/getting_started_with_autotest Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 27. Garantir la couverture avec rcov sudo gem install rcov ● rake spec:rcov ● http://eigenclass.org/hiki.rb?rcov Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 29. Intégration Continue http://cruisecontrolrb.thoughtworks.com cruise add <name> -u <url> cruise start Le lapin il est ROUGE? Le Build il est cassé! http://nabaztag.rubyforge.org/ Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 32. spec/models (méthodes Métier) Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 33. spec/models (Finders) Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 34. specs/fixtures Quelque problèmes: associations, lisibilité ● Mais ça s'améliore dans Rails 2.0 (un peu) ● Alternatives: ● Fixture scenarios: http://errtheblog.com/post/7708 – Tests exemplars: – http://evang.eli.st/blog/2007/8/8/doin-the-fixtures-plugin-thing Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 36. Autres “matchers“ Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 37. Spécifier les Vues? Problème: Les vues changent tout le temps ! Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 38. Exemple de spec/views Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 39. Selenium Tests d'intégration + automatiser les tests d'acceptation ● des utilisateurs Vérifier si l'application fonctionne avec tous les ● butineurs du marché Compatible avec: ● Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 40. Selenium – le film Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
  • 41. Selenium specs 90% de la spec GENERE AVEC SELENIUM-IDE !!!
  • 42. Merci de votre attention! Questions - Réponses 42 Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.