2017-09-03 11 views
2

PhpUnit 6.3を使用してhelloWorld()の機能をテストします。PHP 7.1で書かれています。私は、コマンドラインから直接そのPHPファイルを実行した場合、テストはOKで動作します。私は私の設定ファイルに依存している場合はPhpUnitの設定ミス:<directory>を使用した場合、テストは実行されません。

> php C:\path\to\phpunit.phar C:\project\hello-world\hello-world_tests.php 
    OK <1 test, 1 assertion> 

、何のテストが実行されません。ここで

> php C:\path\to\phpunit.phar --configuration C:\project\phpunit.xml 
    No tests executed! 

が私のフォルダ構造であります:

:ここ

project/ 
    phpunit.xml 
    phpunit.phar 
    hello-world/ 
     hello-world.php 
     hello-world_test.php 

は私の設定ファイル、phpunit.xmlですfileノードでdirectoryノードの交換は

<phpunit> 
    <testsuites> 
     <testsuite name="Test suite"> 
      <directory>./hello-world</directory> 
     </testsuite> 
    </testsuites> 
</phpunit> 

作業の事を取得します。素敵なのですが、私は、私はもともとdirectoryノードを持っていた理由である、個別にすべてのテストファイルを一覧表示したくない

<file>./hello-world/hello-world_test.php</file> 

+0

AFAIR PHPUnitは、末尾に 'Test'という名前のファイルのみをピックアップし、ファイル拡張子をインクルードする場合は' helloWorldTest.php'にします。 – xmike

答えて

2
<phpunit> 
    <testsuites> 
     <testsuite name="Test suite"> 
      <directory suffix="_test.php">./hello-world</directory> 
     </testsuite> 
    </testsuites> 
</phpunit> 
関連する問題