Categories
php

PHP unit

测试用例例子

namespace Tests\Unit;


//use PHPUnit\Framework\TestCase;
//转换成Tests\TestCase 才能正确初始化laravel Application

use Tests\TestCase;

class ExampleTest extends TestCase
{

    //前置条件
     public function setUp()
    {
        parent::setUp();
    }

    /**
     * A basic test example.
     *
     * @return void
     */
    //测试的方法一定要test开头
    public function testBasicTest()
    {
        print "\n";
        echo("进入测试");
        $this->assertTrue(true);
    }
}

执行测试用例:


php vendor/phpunit/phpunit/phpunit ./tests/Unit/ExampleTest.php

查看命令情况:

php vendor/phpunit/phpunit/phpunit -h 

Leave a Reply