先来直接运行,cmd先进入根目录,然后进入tests或是test文件夹
运行命令行:..vendorinphpunit ExampleTest.php
laravel/lumen中集成了PHPUnit, 测试的配置文件为根目录下的phpunit.xml,该配置文件为我们做好了所有配置工作。
use LaravelLumenTestingDatabaseMigrations; use LaravelLumenTestingDatabaseTransactions; class ExampleTest extends TestCase { /** * A basic test example. * * @return void */ public function testExample() { $this->get('/');//设定访问路由 $this->assertEquals( $this->app->version(), $this->response->getContent()//判断访问结果与期望值是否一致 ); } }
可参考:
http://laravelacademy.org/post/2232.html
https://docs.golaravel.com/docs/4.0/testing/
http://www.cnblogs.com/pengzhendong/p/5017557.html
解决
'..vendorinphpunit' 不是内部或外部命令,也不是可运行的程序或批处理文件。
进入vendorin 运行 phpunit ../../tests/XXXTest.php
相关:https://laravel-china.org/docs/lumen/5.3/testing/1895