Estou tentando usar os dataProviders do PHPUnit 12 para fornecer dados a uma função para teste, mas não consigo fazer funcionar.
Aqui está meu teste de unidade (que fica em tests/TestTest.php
):
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class TestTest extends TestCase
{
public static function dataProvider(): array
{
return [['a'], ['b']];
}
#[DataProvider("dataProvider")]
public function testTest($var): void
{
$this->assertTrue(true);
}
}
Quando corro, ./vendor/bin/phpunit tests
recebo isso:
PHPUnit 12.0.0 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.14
E 1 / 1 (100%)
Time: 00:00.019, Memory: 8.00 MB
There was 1 error:
1) TestTest::testTest
ArgumentCountError: Too few arguments to function TestTest::testTest(), 0 passed in C:\path\to\vendor\phpunit\phpunit\src\Framework\TestCase.php on line 1104 and exactly 1 expected
C:\path\to\tests\TestTest.php:12
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Alguma ideia?