Top Qs
Chronologie
Chat
Contexte

PHPUnit

framework de test unitaire pour PHP De Wikipédia, l'encyclopédie libre

PHPUnit
Remove ads

PHPUnit est un framework open source de tests unitaires dédié au langage de programmation PHP[2].

Faits en bref Développé par, Première version ...
Remove ads

Il permet l'implémentation des tests de régression en vérifiant que les exécutions correspondent aux assertions prédéfinies.

Remove ads

Historique

Créé par Sebastian Bergmann en 2004, il intègre les concepts communs aux bibliothèques de tests unitaires xUnit. Le code source de PHPUnit est hébergé sur GitHub[2].

Utilisations

Exemple

<?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;

class StackTest extends TestCase
{
    public function testPushAndPop(): void
    {
        $stack = array();
        $this->assertEquals(0, count($stack));

        array_push($stack, 'foo');
        $this->assertEquals('foo', $stack[count($stack)-1]);
        $this->assertEquals(1, count($stack));

        $this->assertEquals('foo', array_pop($stack));
        $this->assertEquals(0, count($stack));
    }
}
Remove ads

Références

Voir aussi

Loading content...
Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads