phpunit官網:http://www.phpunit.de/
有兩個主要的版本,依php版本決定
兩種方法
其他PHPUnit官網寫很清楚,而且很多觀念教學,真棒
有兩個主要的版本,依php版本決定
- PHPUnit 3.7 requires PHP 5.3.3
- PHPUnit 3.8 requires PHP 5.4.7
兩種方法
- 直接使用phpunit
https://github.com/sebastianbergmann/phpunit/
<php include "phth to PHPUnit"; class StackTest extends PHPUnit_Framework_TestCase { public function testPushAndPop() { $stack = array(); $this->assertEquals(0, count($stack)); array_push($stack, 'foo'); $this->assertEquals('foo', $stack[count($stack)-1]); $this->assertEquals(1, count($stack)); $this->assertEquals('foo', array_pop($stack)); $this->assertEquals(0, count($stack)); } } ?>
- 安裝phpunit
vi composer.jsonwget https://phar.phpunit.de/phpunit.phar chmod +x phpunit.phar mv phpunit.phar /usr/local/bin/phpunit
{
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}
composer install
程式裡加上
require 'vendor/autoload.php';
其他PHPUnit官網寫很清楚,而且很多觀念教學,真棒
- Install PHPUnit
- Learn how to write tests.
- Learn how to run tests.
- Learn how to organize tests.
- Learn how to set up phpUnderControl for continuous integration.
- Read the documentation (ePub, PDF, Single HTML).
沒有留言:
張貼留言