小编And*_*nes的帖子

ArgumentCountError:函数 phpunit 的参数太少

我正在尝试使用创建一些编程测试phpUnit。我需要使用数据提供程序,但每次尝试时,它都会引发错误。我什至使用 文档中给出的示例phpUnit

 /**
 * @dataProvider additionWithNonNegativeNumbersProvider
 */
public function testAdd($a, $b, $expected)
{
    $this->assertSame($expected, $a + $b);
}

public function additionWithNonNegativeNumbersProvider()
{
    return [
        [0, 1, 1],
        [1, 0, 1],
        [1, 1, 3]
    ];
}
Run Code Online (Sandbox Code Playgroud)

我期望输出是:

There was 1 failure:
1) DataTest::testAdd with data set #3 (1, 1, 3)
Failed asserting that 2 is identical to 3.
Run Code Online (Sandbox Code Playgroud)

但它是:

ArgumentCountError : Too few arguments to function controllerTests::testAdd(), 0 passed in phar://C:/xampp/htdocs/2019-1-qa-grupo1/myss/Tests/phpunit-8.1.2.phar/phpunit/Framework/TestCase.php on line 1172 and exactly 3 …
Run Code Online (Sandbox Code Playgroud)

php phpunit

2
推荐指数
1
解决办法
6308
查看次数

标签 统计

php ×1

phpunit ×1