Php 测试计数大于CodeCeption中数据提供程序的数据计数
我在CodeCeption中有一个Php 测试计数大于CodeCeption中数据提供程序的数据计数,php,phpunit,codeception,Php,Phpunit,Codeception,我在CodeCeption中有一个Cest,它使用数据提供程序: <?php class MyCest { /** * @param \Codeception\Example $example * @dataProvider MyDataProvider */ public function MyTestCase(Codeception\Example $example) { echo "Name: ", $exam
Cest
,它使用数据提供程序
:
<?php
class MyCest
{
/**
* @param \Codeception\Example $example
* @dataProvider MyDataProvider
*/
public function MyTestCase(Codeception\Example $example)
{
echo "Name: ", $example['name'], ", Age: ", $example['age'];
}
public function MyDataProvider() {
$data = [
["name" => 'Alice', "age" => 20],
["name" => 'Tom', "age" => 35],
["name" => 'Bob', "age" => 60],
];
return $data;
}
}
我复习;其示例意味着测试的数量等于从dataProvider
方法返回的数据项的数量
似乎
数据提供程序的调用已被视为测试用例本身。所有Cest
类的公共方法都作为测试执行,
为了避免这种情况,请将MyDataProvider设置为受保护或重命名为MyDataProvider
记录于
zeinab@zeinab:~/PhpstormProjects/api-testing$ php vendor/bin/codecept run tests/api/MyCest.php
Codeception PHP Testing Framework v2.5.1
Powered by PHPUnit 7.1.5 by Sebastian Bergmann and contributors.
Running with seed:
Api Tests (4) --------------------------------------------------------------------------------------
✔ MyCest: My test case | "Alice",20 (0.00s)ice, Age: 20
✔ MyCest: My test case | "Tom",35 (0.00s)m, Age: 35
✔ MyCest: My test case | "Bob",60 (0.00s)b, Age: 60
✔ MyCest: My data provider (0.00s)
----------------------------------------------------------------------------------------------------
Time: 63 ms, Memory: 10.00MB
OK (4 tests, 0 assertions)