tanaka's Programming Memo

プログラミングについてのメモ。

phpunit.xmlファイルでグループを指定する

実行する対象のテストを、@groupアノテーションで設定したグループで指定するphpunit.xmlファイルの書き方です。

sampleTestという名前で、phpunit.xmlと同じ場所にあるtestファイルのうち、targetGroupという名前を設定したグループのみをテストするには、以下のようにします。

<phpunit>
  <testsuites>
    <testsuite name="sampleTest">
      <directory>.</directory>
    </testsuite>
  </testsuites>
  <groups>
    <include>
      <group>targetGroup</group>
    </include>
  </groups>
</phpunit>

注意

  • groupタグは途中で改行は入れず、続けて書く。そうしないとグループを認識してくれない。