您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit中参数configuration的使用
发布时间:2021-09-20 15:19:14编辑:雪饮阅读()
上篇中有写了autoload.php对组织测试中所需要的类进行加载,然后使用参数--bootstrap来载入这个autoload.php。
那么其实除了上面这种方式,还可以在如上篇中的组织测试的项目中建立一个phpunit.xml的配置文件在该文件中用bootstrap来指定也是可以的,并且这种方式也是我比较推荐比较喜欢的一种。
Phpunit.xml:
<phpunit bootstrap="src/autoload.php">
</phpunit>
</phpunit>
那么运行时候可以这样:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.3.4nts\php.exe D:\phpstudy_pro\Extensions\php\php7.3.4nts\phpunit-9.5.8.phar --configuration C:\Users\Administrator\PhpstormProjects\untitled\organizing\phpunit.xml C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
.. 2 / 2 (100%)
Time: 00:00.005, Memory: 20.00 MB
OK (2 tests, 3 assertions)
并且会发现configuration参数后面也可以用等号=,如:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.3.4nts\php.exe D:\phpstudy_pro\Extensions\php\php7.3.4nts\phpunit-9.5.8.phar --configuration=C:\Users\Administrator\PhpstormProjects\untitled\organizing\phpunit.xml C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
.. 2 / 2 (100%)
Time: 00:00.006, Memory: 20.00 MB
OK (2 tests, 3 assertions)
关键字词:phpunit,configuration
上一篇:phpunit组织测试