PHPUnit 3.6中的bootstrap选项发生了什么变化?

时间:2012-05-02 16:55:52

标签: php phpunit bootstrapping

bootstrap配置选项在最新版本的phpunit.xml文档中已注释掉: http://www.phpunit.de/manual/current/en/appendixes.configuration.html

实际上,它似乎并没有在我的配置文件中读取它。为什么是这样?如何配置phpunit 3.6以自动包含引导程序文件?

在我看来,设置项目非常有用,因此PHPUnit会自动配置引导程序文件,而运行PHPUnit的人不必知道它,所以他们可以这样做:

> phpunit

而不是:

> phpunit --bootstrap [file]

2 个答案:

答案 0 :(得分:0)

bootstrap文件应该在测试之前运行,它是phpunit的可用命令行选项

--bootstrap <file>

有关cli选项的更多信息:

http://www.phpunit.de/manual/current/en/textui.html#textui.clioptions

我从未使用xml配置文件作为bootstrap选项,因此我不知道为什么它不能或不再工作,但希望cli的工作方式与我的相似:)

答案 1 :(得分:0)

在PHPUnit的配置文件中,在版本3.4中,您可以包含一个引导程序文件,如下所示:

<phpunit backupGlobals="false"
         backupStaticAttributes="true"
         bootstrap="/path/to/bootstrap.php"

http://www.phpunit.de/manual/3.4/en/appendixes.configuration.html

但是从3.5开始,此选项已被注释掉,因此您无法再使用它:

<phpunit backupGlobals="true"
         backupStaticAttributes="false"
         <!--bootstrap="/path/to/bootstrap.php"-->

http://www.phpunit.de/manual/3.5/en/appendixes.configuration.html

我找不到任何关于禁用此选项的原因的参考。我查找了PHPUnit 3.5的发行说明,看看他们是否提到了什么,但我发现根本没有提到bootstrap。

http://sebastian-bergmann.de/archives/897-PHPUnit-3.5.html

https://github.com/sebastianbergmann/phpunit/blob/3.5/README.markdown

我仍然欢迎任何知道为什么删除此选项的人发表评论。