Outils pour utilisateurs

Outils du site


informatique:php:behaviour-driven_development_php

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
informatique:php:behaviour-driven_development_php [17/06/2026 09:36] – créée cyrilleinformatique:php:behaviour-driven_development_php [17/06/2026 10:22] (Version actuelle) – [Behat] cyrille
Ligne 3: Ligne 3:
 Le Behaviour-Driven Development ([/glossaire/BDD|BDD]]) est idéal pour les tests d'acceptation et la collaboration entre équipes techniques et métiers. Le Behaviour-Driven Development ([/glossaire/BDD|BDD]]) est idéal pour les tests d'acceptation et la collaboration entre équipes techniques et métiers.
  
-**Behat**: Framework BDD le plus connu pour PHP, inspiré de [[https://cucumber.io|Cucumber]]. Permet de décrire le comportement de l'application en langage naturel (Gherkin). Intégration facile avec Symfony et Laravel. https://github.com/Behat/Behat+Le BDD est bien adapté pour les [[/informatique/ai_lm/ai_coding|assistants IA]] : 
 +  * https://docs.behat.org/en/latest/behat_and_ai.html 
 + 
 +**Behat**: Framework BDD le plus connu pour PHP, inspiré de [[https://cucumber.io|Cucumber]]. Permet de décrire le comportement de l'application en langage naturel (Gherkin). Intégration facile avec Symfony et Laravel. https://docs.behat.org, https://github.com/Behat/Behat
  
  
 **Codeception**:  Framework de test PHP qui supporte le style BDD. provides high-level domain language for tests. Tests are represented as a set of user's actions. Symfony, Laravel, Zend Framework, Yii, Phalcon are supported. https://codeception.com **Codeception**:  Framework de test PHP qui supporte le style BDD. provides high-level domain language for tests. Tests are represented as a set of user's actions. Symfony, Laravel, Zend Framework, Yii, Phalcon are supported. https://codeception.com
  
-Abandonné:+Abandonnés:
   * [[https://github.com/danielstjules/pho|Pho]] last commit 2017-04   * [[https://github.com/danielstjules/pho|Pho]] last commit 2017-04
   * [[https://github.com/olbrich/cuke4php|Cuke4php]] last commit 2013-12   * [[https://github.com/olbrich/cuke4php|Cuke4php]] last commit 2013-12
 +
 +===== Behat =====
 +
 +How does Behat know what to do when it sees ''Given there is a "Sith Lord Lightsaber", which costs £5''?
 +
 +You tell it: you write PHP code inside your context class (FeatureContext in our case) and tell Behat that this code represents a specific scenario step (via an attribute with a pattern):
 +
 +<code php>
 +#[Given('there is a(n) :arg1, which costs £:arg2')]
 +public function thereIsAWhichCostsPs($arg1, $arg2)
 +{
 +    throw new PendingException();
 +}
 +</code>
 +
 +Those patterns could be quite powerful, but at the same time, writing them for all possible steps manually could become extremely tedious and boring.
 +
 +**That’s why Behat does it** for you :
 +
 +<code>
 +--- FeatureContext has missing steps. Define them with these snippets:
 +
 +    #[Given('there is a :arg1, which costs £:arg2')]
 +    public function thereIsAWhichCostsPs($arg1, $arg2)
 +    {
 +        throw new PendingException();
 +    }
 +</code>
 +
informatique/php/behaviour-driven_development_php.1781681763.txt.gz · Dernière modification : de cyrille

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki