yii2的phpunit test

## 参照网站

phpunit官方网站  http://www.phpunit.cn/  https://phpunit.de/

## 代码示例

https://github.com/sebastianbergmann/money/blob/master/tests/MoneyTest.php

```php

use PHPUnit\Framework\TestCase;

class MoneyTest extends TestCase

```

## 简单步骤

1. 按照网站所示下载phpunit6并放到/usr/local/bin

2. 写testcode

3. yii2的话,跟 phpunit --bootstrap src/autoload.php tests/MoneyTest有点不一样

   要把src/autoload.php变成 web/index.php ,才能包含所有的require的文件

   但是web/index.php ,最后一行,(new yii\web\Application($config))->run();

   换成 return (new yii\web\Application($config))->run();

4. 不想用yii2的codeception,因为除了unit之外还包含了acceptance和functional,太重

猜你喜欢

转载自fighter1945.iteye.com/blog/2365937