Outils pour utilisateurs

Outils du site


informatique:php:behaviour-driven_development_php

Ceci est une ancienne révision du document !


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.

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();
    }
informatique/php/behaviour-driven_development_php.1781682228.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