Home TIL: When Filtering Tests..

Enter a search term to find articles.
2021-01-07
198

TIL: When Filtering Tests..

TIL that you do not need the full class name (or the full method name) when filtering tests to run.

I was working on some documentations writing today when I ran my tests with a mistyped User filter and to my surprise, it loaded and ran all tests with the word User on class names and methods.

Below is how it looked like after I ran the command (some tests have been redacted)..

➜  p2p git:(develop) ./vendor/bin/phpunit --filter=User
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

Batch Import Job (Tests\Unit\BatchImportJob)
 ✔ It belongs to a user

Company (Tests\Unit\Company)
 ✔ It belongs to many users

Contract (Tests\Unit\Contract)
 ✔ It belongs to many users

Media Security Check (Tests\Unit\MediaSecurityCheck)
 ✔ It belongs to a user

User Setting (Tests\Unit\UserSetting)
 ✔ It belongs to a supervisor
 ✔ It belongs to a user
 ✔ It belongs to a delegate

Companies Deactivation (Tests\Feature\Admin\CompaniesDeactivation)
 ✔ Deactivating a company also deactivates its users

User Change Password (Tests\Feature\Admin\UserChangePassword)
 ✔ Can change password of a user
 ✔ Can resend email password reset to user

User Contracts (Tests\Feature\Admin\UserContracts)
 ✔ Can attach a contract to a user

User Deactivations (Tests\Feature\Admin\UserDeactivations)
 ✔ Can deactivate a user
 ✔ Deactivated users cannot login
 ✔ Can reactivate a user

User Export (Tests\Feature\Admin\UserExport)
 ✔ Can export users

User Settings (Tests\Feature\Admin\UserSettings)
 ✔ Can update user settings

Users (Tests\Feature\Client\Users)
 ✔ Can list all users
 ✔ Can get user details
 ✔ Can only get details of users in the same company

User Filters (Tests\Feature\Filters\UserFilters)
 ✔ It can load user companies
 ✔ It can be filtered by company association

User Picklists (Tests\Feature\Supplier\UserPicklists)
 ✔ Can update picklist

Users (Tests\Feature\Supplier\Users)
 ✔ Can list all users

[Some tests have been redacted]

Time: 44.64 seconds, Memory: 86.50 MB

OK (83 tests, 204 assertions)

Marvin Quezon

Full Stack Web Developer
Marvin Quezon · Copyright © 2024 · Privacy · Sitemap