Laravel 测试指南:从基础到高级应用
1. 测试命名规则
在 Laravel 中,测试系统默认会运行 tests 目录下文件名以 Test 结尾的文件,例如 tests/ExampleTest.php 会被默认执行。
对于 PHPUnit 测试,只有方法名以 test 开头的方法,或者带有 @test 文档块的方法才会被运行。以下是示例:
class Naming
{
public function test_it_names_things_well()
{
// Runs as "test it names things well"
}
public function testItNamesThingsWell()
{
// Runs as "It names things well"
}
/** @test */
public function it_names_things_well()
{
// Runs as "it names things well"
}
public function it_names_things_well()
{
// Doesn't run
}
}
2. 测试环境
Laravel 应用运行时会有一个当前的“环
超级会员免费看
订阅专栏 解锁全文
1495

被折叠的 条评论
为什么被折叠?



