Laravel PHPUnit Testing
2021-12-08 03:49:12 0 举报
AI智能生成
Laravel PHPUnit Testing
作者其他创作
大纲/内容
Environment
phpunit.xml
APP_ENV="testing"
CACHE_DRIVER="array"
SESSION_DRIVER="array"
QUEUE_DRIVER="sync"
suffix="Test.php"
testsuite: Feature[./tests/Feature]
testsuite: Unit[./tests/Unit]
filter -> whitelist ->directory
.env.testing
Database_Connection
SMTP Mail
API Account
3 party API
Createing Tests
Artisan make:SampleTest
Artisan make:SampleTest --feature
Artisan make:SampleTest --unit
Manual Create file
Runing Tests
./vendor/bin/phpunit
./vendor/bin/phpunit --coverage-html
php artisan test
php artisan test --testsuite=Feature --stop-on-failure
php artisan test --testsuite=Unit --stop-on-failure
php artisan test --coverage-html
php artisan test --parallel
php artisan test --parallel --processes=4
php artisan test --parallel --recreate-databases
单元测试的任务
接口功能测试
局部数据结构测试
变量有无初始值
变量是否溢出
边界条件测试
变量没有赋值null
变量是数字
主要边界
溢出边界
临近边界
变量是字符串
引用字符变量的边界
空字符串
对字符串长度应用数值变量的边界
变量是集合
变量有规律
所有独立执行通路测试
代码覆盖率
语句覆盖
判定覆盖
条件覆盖
路径覆盖
相关工具
Coberture
Console Tests
expectsQuestion
expectsOutput
assertExitCode
expectsConfirmation
Database Tests
Resetting The Database After Each Test
Defining Model Factories
Generating Factories
Creating Models Using Factories
Factory Relationships
Has Many Relationships
Belongs To Relationships
Many To Many Relationships
Polymorphic Relationships
Defining Relationships Within Factories
Running Seeders
Available Assertions
assertDatabaseCount
assertDatabaseHas
assertDatabaseMissing
assertDeleted
assertModelExists
assertModelMissing
Http Tests
expectsQuestion
expectsOutput
assertExitCode
expectsConfirmation
Browser Tests
Browser Basics
Creating Browsers
Navigation
Resizing Browser Windows
Browser Macros
Authentication
Cookies
Executing JavaScript
Taking A Screenshot
Storing Console Output To Disk
Storing Page Source To Disk
Interacting With Elements
Dusk Selectors
Text, Values, & Attributes
Interacting With Forms
Attaching Files
Pressing Buttons
Clicking Links
Using The Keyboard
Using The Mouse
JavaScript Dialogs
Scoping Selectors
Waiting For Elements
Scrolling An Element Into View
Available Assertions
Pages
Components
Continuous Integration
Mocking
Mocking Objects
Mocking Facades
Bus Fake
Event Fake
HTTP Fake
Mail Fake
Notification Fake
Queue Fake
Storage Fake
Interacting With Time
0 条评论
下一页