如何使用特定数据集运行 phpunit 单元测试

admin 阅读:127 2024-08-13

如何使用特定数据集运行 phpunit 单元测试

今天我正在运行我的测试,但测试失败了:

testscommonbusinesslogicxxxxxlogictest::testinvalidxx with data set #9 ([['dsadsa', 'dsafsdfsd', 1234.23, -1234.23, '', 'dsadsa']]) failed asserting that 1 matches expected 0.

/var/www/html/tests/common/businesslogic/asfalistiko/formsectionelogictest.php:102 /var/www/html/tests/common/businesslogic/xxx/xxlogictest.php:301

我尝试调试这个问题,但我的数据集中有很多数据。失败的情况仅适用于特定的数据集,我需要仅使用特定的数据集(数据集 #9)运行失败的测试 testinvalidxx。

为了做到这一点,我启动了 phpunit,如下所示:

./vendor/bin/phpunit ./tests/common/businesslogic/xxx/xxlogictest.php --filter="testinvalidxx#9"

在上面的命令中,请注意提供的 --filter 值。过滤值为:

testInvalidXX#9

过滤值由2部分组成:

  1. 测试名称 testinvalidxx
  2. 数据集索引#9

通过使用此过滤器,phpunit 将仅运行数据集索引 #9 的指定测试用例,让您可以专注于调试特定的失败。


本教程应该帮助您使用 phpunit 对特定数据集索引运行特定测试。

立即学习PHP免费学习笔记(深入)”;

声明

1、部分文章来源于网络,仅作为参考。
2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!