Ubuntu 怎样安装phpunit

安装方法:

pear upgrade PEAR
sudo pear channel-discover pear.phpunit.de
sudo pear install --alldeps phpunit/PHPUnitpear help pear install phpunit/PHPUnit_Selenium
pear list phpunit

测试程序

目标程序 :Demo.php
<?php
class Demo {
    public function sum($a,$b) {
        return $a+$b;
    }
    public function subtract($a,$b){
        return $a-$b;
    }
}
用例程序 : DemoTest.php 
<?php
    require ('./Demo.php');

    class DemoTest extends PHPUnit_Framework_TestCase {
        public function testSum() {
            $demo = new Demo();
            $this->assertEquals(4,$demo->sum(2,2));
            $this->assertNotEquals(2,$demo->sum(3,1));
        }
    }

 

posted on 2013-06-04 18:30  lsl8966  阅读(146)  评论(0编辑  收藏  举报