无法在 PHPUnit 中使用数据提供程序运行单个测试
使用命令行运行测试时,我遇到了一个问题:如果我像这样运行phpunit:
phpunit -–no-configuration -–filter testAdd DataTest DataProviderTest.php
它工作正常。但是我们使用正则表达式来准确指定我们要测试的方法的名称:
phpunit -–no-configuration -–filter /::testAdd$/ DataTest DataProviderTest.php
不幸的是,第二种方法不起作用。源代码是:
<?php
class DataTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider provider
     */
    public function testAdd($a, $b, $c)
    {
        $this->assertEquals($c, $a + $b);
    }
    public function provider()
    {
        return array(
          array(0, 0, 0),
          array(0, 1, 1),
          array(1, 0, 1),
          array(1, 1, 3)
        );
    }
}
?>
 
					 
				 
				    		 
				    		 
				    		 
				    		