Ceci est une ancienne révision du document !
Table des matières
Behaviour-Driven Development pour Php
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 BDD est bien adapté pour les assistants IA :
Behat: Framework BDD le plus connu pour PHP, inspiré de 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
Abandonnés:
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):
#[Given('there is a(n) :arg1, which costs £:arg2')] public function thereIsAWhichCostsPs($arg1, $arg2) { throw new PendingException(); }
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 :
--- 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();
}
