PHPUnit_TextUI_命令测试路径中的所有测试,不带--configuration

PHPUnit_TextUI_命令测试路径中的所有测试,不带--configuration,php,phpunit,Php,Phpunit,我以以下方式使用PHPUnit_TextUI_命令 $path = 'a/path/to/phpunit.xml'; if(!file_exists($path)) throw new Exception("Cannot read PHPUnit config file at '" . $path . "'"); $argv = array( '--configuration', $path, ); $_SERVER['argv'] = $argv; PHPUnit_Tex

我以以下方式使用PHPUnit_TextUI_命令

$path = 'a/path/to/phpunit.xml';

if(!file_exists($path))
    throw new Exception("Cannot read PHPUnit config file at '" . $path . "'");

$argv = array(
    '--configuration', $path,
);
$_SERVER['argv'] = $argv;

PHPUnit_TextUI_Command::main(false);
这可以正常工作,但需要存在phpunit.xml配置文件

我真正想做的是能够在PHP代码中设置要测试的目录或文件,而不是在静态phpunit.xml文件中。像这样的

$argv = array(
    '--directory', "a/path/to/tests",
);
$_SERVER['argv'] = $argv;

PHPUnit_TextUI_Command::main(false);
你可以用

$argv = array(
    __FILE__,
    'a/path/to/tests',
);
$_SERVER['argv'] = $argv;
如果您的所有案例文件都以
Test.php
结尾

您可以使用
--test suffix
phpunit选项更改后缀