JenkinsでPHPUnitを実行するだけのためのbuild.xml (Apache Ant)。
JenkinsでPHPUnitのテストを走らせるためだけのbuild.xmlです。
「tests」フォルダ以下の「*Test.php」のテストスイートを実行します。
> tuki0918/jenkins_phpunit サンプルコード
### フォルダ階層
workspace │ ├── build.xml └── tests ├── sample1Test.php ├── sample2Test.php └── sample3Test.php
### build.xml
<project name="jenkins project" default="build"> <target name="phpunit"> <exec dir="." executable="phpunit" failonerror="true"> <arg line="--colors tests" /> </exec> </target> <target name="build" depends="phpunit"/> </project>
### tests/sample1Test.php
<?php class UnitTest extends PHPUnit_Framework_TestCase { public function testPushAndPop() { $user = array(); $this->assertEquals(0, count($user)); array_push($user, 'hoge'); $this->assertEquals('hoge', $user[0]); $this->assertEquals(1, count($user)); $this->assertEquals('hoge', array_pop($user)); $this->assertEquals(0, count($user)); } public function testArray() { $array = array(); $this->assertEquals(0, count($array)); } }
### テスト成功時
### テスト失敗時
### コンソール出力のカラー変更
AnsiColorプラグイン