« You might think about Behat as a tool to teach your clients about testing, but in reality it’s a tool to teach you about client business. » Konstantin Kudryashov (@everzet) https://speakerdeck.com/u/everzet/p/behat-by-example
login using a form! ! Scenario: Login with bad credentials! Given I am on the homepage! And I follow "Log in"! And I press "Log in"! Then I should see "Bad credentials"! ! Given I fill in "username" with "foo"! And I fill in "password" with "bar"! And I press "Log in"! Then I should see "Bad credentials"! Q ? Q ? C ?
sont en échec • Le développeur écrit le code des steps manquants • Lancement des tests • Les tests sont en échec • Le développeur produit les éléments (fonctionnels) nécessaires • Lancement des tests • Les tests passent
des remplaçants des tests unitaires (et inversement). Le test fonctionnel vous assure qu’une fonctionnalité est conforme aux attentes alors que le test unitaire vous assure que le code mis en place pour l’implémenter est stable et robuste.
[--out="..."] [--lang="..."] [--[no-]ansi] [-- [no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [-- [no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [-- name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--rerun="..."] [-- append-snippets] [features]! U • --format : Choisissez le format de sortie à la volée (dans certains cas, à utiliser avec –-out) • --lang : Choisissez la langue utilisée pour rédiger vos tests • --definitions : Obtenez la liste des steps disponibles • --tags : Lancez vos tests par lots
= Eléments génériques réutilisables Il faut développer une partie spécifique(principalement des contextes contenant les définitions de steps) au projet pour pouvoir utiliser un vocabulaire commun à tous. Feature: Login! As a visitor! I should be able to login using a form! ! Scenario: Login with bad credentials! Given I am on the homepage! And I follow "Log in"! And I press "Log in"! Then I should see a ".alert" element containing "Bad credentials"!
aux Contexts/Formatters spécifiques au projet http://docs.behat.org/quick_intro.html#writing-your-step-definitions Q q p : • Utiliser atoum pour générer les assertions https://github.com/mageekguy/atoum/wiki/atoum-et-Behat • Test distribué grâce à Gearman http://extensions.behat.org/gearman/ • Behat Viewer : analyseur de rapport http://behat-viewer-ci.jubianchi.fr
aux Contexts/Formatters spécifiques au projet http://docs.behat.org/quick_intro.html#writing-your-step-definitions Q q p : • Utiliser atoum pour générer les assertions https://github.com/mageekguy/atoum/wiki/atoum-et-Behat • Test distribué grâce à Gearman http://extensions.behat.org/gearman/ • Behat Viewer : plateforme d’analyse et de centralisation des rapports http://behat-viewer-ci.jubianchi.fr