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

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

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

    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.
    3. Background
    4. Qui est-ce?
    5. 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/
    6. Qui est-ce?
    7. 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
    8. Qui est-ce?
    9. MARTIN FOWLER 2000: “Refactoring” ● article sur l'Intégration ● Continue http://www.martinfowler.com
    10. 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)
    11. Livres pour 2008
    12. Théorie
    13. Anatomie d'une spécification Comportement (contexte) Exemple Exemple
    14. 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.
    15. Langage naturel (en VO)
    16. ruby spec/project_spec.rb
    17. Résultat Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
    18. Customizer Rspec Pas très lisible! Solution: écrire son propre “Matcher”
    19. http://martinfowler.com/articles/mocksArentStubs.html Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
    20. 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.
    21. Tests = Spécifications
    22. Tests = Documentation Exemples exécutable = ● Documentation toujours á jour Plus besoin de rdoc ;-) ● Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
    23. Pratique
    24. 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.
    25. 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.
    26. 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.
    27. Couverture détaillée
    28. 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.
    29. CruiseControl.rb
    30. Exemple de spec/models http://edgerepo.com/svn/opensource/ruby/plugins/rspec_expectation_matchers/
    31. spec/models (méthodes Métier) Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
    32. spec/models (Finders) Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
    33. 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.
    34. Exemple de spec/controllers
    35. Autres “matchers“ Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
    36. Spécifier les Vues? Problème: Les vues changent tout le temps ! Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
    37. Exemple de spec/views Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
    38. 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.
    39. Selenium – le film Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.
    40. Selenium specs 90% de la spec GENERE AVEC SELENIUM-IDE !!!
    41. Merci de votre attention! Questions - Réponses 42 Paris On Rail 2007 – Copyright (c) Garnier Jean-Michel. Licence: Creative Commons.

    + garnierjmgarnierjm, 2 years ago

    custom

    1752 views, 2 favs, 0 embeds more stats

    Presentation given at Paris on Rails 2007

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1752
      • 1752 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 42
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories