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 velezcarivfi
 
French Trip
French TripFrench Trip
French Tripmrverney
 
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’âmeDany Maillard
 
Petite SoiréE Chez Max2
Petite SoiréE Chez Max2Petite SoiréE Chez Max2
Petite SoiréE Chez Max2guest2ae29e
 
Le Petit Chaperon Rouge
Le Petit Chaperon RougeLe Petit Chaperon Rouge
Le Petit Chaperon Rougeguest5c0510
 
Pda Inoxia Janvier 08
Pda Inoxia Janvier 08Pda Inoxia Janvier 08
Pda Inoxia Janvier 08guest03841f
 
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íaNotiGen
 
Parfaits
ParfaitsParfaits
Parfaitscharbu2
 
Arxtech Mobilier Tactile Interactif
Arxtech Mobilier Tactile InteractifArxtech Mobilier Tactile Interactif
Arxtech Mobilier Tactile InteractifArxtech Canada
 
Citations de spiritualite (6)
Citations de spiritualite (6)Citations de spiritualite (6)
Citations de spiritualite (6)alboflede
 
Leparachute Tr Sbeautexte 1
Leparachute Tr Sbeautexte 1Leparachute Tr Sbeautexte 1
Leparachute Tr Sbeautexte 1charbu2
 
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 FinaleAfet
 
S Curit Routi Re
S Curit Routi ReS Curit Routi Re
S Curit Routi Reguestf344b8
 

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)

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 Coursepeter_marklund
 
Why Architecture in Web Development matters
Why Architecture in Web Development mattersWhy Architecture in Web Development matters
Why Architecture in Web Development mattersLars Jankowfsky
 
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 developmentNicolas Alpi
 
Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422journeyer
 
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 ...Atlassian
 
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 Abhishek Singh
 
Crate - ruby based standalone executables
Crate - ruby based standalone executablesCrate - ruby based standalone executables
Crate - ruby based standalone executablesJeremy Hinegardner
 
Kamaelia - Networking Using Generators
Kamaelia - Networking Using GeneratorsKamaelia - Networking Using Generators
Kamaelia - Networking Using Generatorskamaelian
 
Deploying And Monitoring Rails
Deploying And Monitoring RailsDeploying And Monitoring Rails
Deploying And Monitoring RailsJonathan Weiss
 
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 EducationCybera Inc.
 
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...Etiene Dalcol
 
Rails Conf Europe 2007 Notes
Rails Conf  Europe 2007  NotesRails Conf  Europe 2007  Notes
Rails Conf Europe 2007 NotesRoss Lawley
 
InterCon - Ruby e Rails
InterCon - Ruby e RailsInterCon - Ruby e Rails
InterCon - Ruby e RailsFabio Akita
 
Katello on TorqueBox
Katello on TorqueBoxKatello on TorqueBox
Katello on TorqueBoxlzap
 
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 RubyHiroshi SHIBATA
 
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

2015 07 08_genevarb_maniok_presentation
2015 07 08_genevarb_maniok_presentation2015 07 08_genevarb_maniok_presentation
2015 07 08_genevarb_maniok_presentationJean-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 cucumberJean-Michel Garnier
 
Tests d'Acceptance utilisateur avec cucumber
Tests d'Acceptance utilisateur avec cucumberTests d'Acceptance utilisateur avec cucumber
Tests d'Acceptance utilisateur avec cucumberJean-Michel Garnier
 
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-gridJean-Michel Garnier
 
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)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 TestingJean-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

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Último (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

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.