2 php windows phpunit composer-php
我想在我的本地Windows机器上运行phpunit测试..(使用wamp)..
我已经全局安装了composer ..并且phpunit安装在我的本地目录中..
文件夹结构..
_________tests
| |
| |______PagesTest.php
|
|________vendor
|
|______bin
|
|_____phpunit
Run Code Online (Sandbox Code Playgroud)
在我的localroot(www)..我创建了一个phpunit.xml文件..
<?xml version="1.0" encoding="UTF-8"?>
<phpunit convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
convertErrorsToExceptions="true"
backupStaticAttributes="false"
processIsolation="false"
stopOnFailure="false"
backupGlobals="false"
syntaxCheck="false"
colors="true">
<testsuites>
<testsuite name="Punta Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
Run Code Online (Sandbox Code Playgroud)
在Cmd我试过:
C:\wamp\www\vendor\bin>phpunit PagesTest
Run Code Online (Sandbox Code Playgroud)
输出是
Cannot open file PagesTest.php
Run Code Online (Sandbox Code Playgroud)
我不知道如何使用composer运行这个PagesTest.php文件
好的,PHPUnit正在运行,但没有找到Test文件,因为没有加载Composer Autoloader.
您可以通过为PHPUnit添加配置文件来解决此问题,该配置文件定义属性bootstrap并设置Composer Autoloader文件.
示例 phpunit.xml.dist
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="My Project - TestSuite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
Run Code Online (Sandbox Code Playgroud)
然后只需运行PHPUnit命令:
$ ./vendor/bin/phpunit
Run Code Online (Sandbox Code Playgroud)
在Windows上只需翻转斜杠: C:\> .\vendor\bin\phpunit
PHPUnit将自动检测配置文件(phpunit.xml.dist)并在其引导阶段加载Composer Autoloader.
| 归档时间: |
|
| 查看次数: |
4914 次 |
| 最近记录: |