File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 6
6
Laravel PHPUnit 测试
7
7
8
8
以 ` Laravel 5.8 ` 为例,在框架初始化过程中通过 ` Composer ` 安装了 ` PHPUnit ` 7(也可以手动升级到 PHPUnit 8),并且在项目根目下创建了 tests 目录用于存放测试文件:
9
+ ![ ] ( https://laravelacademy.org/wp-content/uploads/2019/04/4527f09add5ed4a4007f97be975bf67d.jpg )
10
+
9
11
10
12
Laravel 测试目录结构
11
13
@@ -77,7 +79,7 @@ Laravel 框架默认通过 <testsuites> 定义了两个 <testsuite>,分别是
77
79
78
80
在运行 phpunit 命令时,我们可以通过相应测试套件的名称匹配要执行的测试用例:
79
81
80
-
82
+ ![ ] ( https://laravelacademy.org/wp-content/uploads/2019/04/a1c39cb20b0dc9db1ce781110f1ac7e5.jpg )
81
83
82
84
更多测试套件的配置选项可以参考官方文档。
83
85
@@ -86,7 +88,7 @@ Laravel 框架默认通过 <testsuites> 定义了两个 <testsuite>,分别是
86
88
87
89
这样,我们在运行 phpunit 时加上 --coverage-html . 参数,就可以在根目录下生成 HTML 格式的测试覆盖率报告文档了:
88
90
89
-
91
+ ![ ] ( https://laravelacademy.org/wp-content/uploads/2019/04/4d2e87763b84e5610063f711f7ef2d9b.jpg )
90
92
91
93
打开对应的 index.html 文档,就可以在浏览器中看到测试覆盖率报告页面:
92
94
You can’t perform that action at this time.
0 commit comments