如果从不同目录运行,则PHPUnit失败
我在一个名为“library”的文件夹中有我的命名空间webapp。如果我在目录中并运行如果从不同目录运行,则PHPUnit失败,php,unit-testing,testing,phpunit,Php,Unit Testing,Testing,Phpunit,我在一个名为“library”的文件夹中有我的命名空间webapp。如果我在目录中并运行phpunit测试运行得很好。但是,如果我离开目录并运行phpunitlibrary/phpunit,它会抱怨无法找到使用use语句调用的类 这是我的phpunit.xml,它位于“library”目录中: <?xml version="1.0" encoding="UTF-8"?> <!-- http://phpunit.de/manual/4.1/en/appendixes.confi
phpunit
测试运行得很好。但是,如果我离开目录并运行phpunitlibrary/
phpunit,它会抱怨无法找到使用use
语句调用的类
这是我的phpunit.xml,它位于“library”目录中:
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="./tests/testsBootstrap.php"
>
<testsuites>
<testsuite name="JTW Framework Test Suite">
<directory>./</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./tests</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./tests/report" charset="UTF-8" yui="true" />
</logging>
</phpunit>
./
./
/测试
下面是使用类(简称)的测试:
问题来自这里:
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="./tests/testsBootstrap.php"
>
就是这样。但是我很好奇为什么它不读取我告诉它运行测试的文件夹中的phpunit.xml;或者至少它不会加载引导程序。因为您可以告诉phpunit运行任何特定文件或任何子目录,所以它会在当前位置查找phpunit.xml文件。这非常有意义。非常感谢。您可以指定PHPUnit配置文件以使用PHPUnit-c/path/to/PHPUnit.xml
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="./tests/testsBootstrap.php"
>
phpunit --bootstrap <path to library>/tests/testBootstrap.php <tests you want to run>