-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test method naming convention #28
Comments
We should really use camelCase for all method names because it's PSR compliant. In the docs they use camelCase. I saw a page in the docs where snake_case was used and created a PR which was accepted by Taylor Otwell right away. Also, books written by Taylor Otwell, Jeffrey Way, and other well-known authors use camelCase in unit test examples. |
There's a PR on laravel's repo that they're using snake case as their convention for methods names in tests. |
camel case is so much harder to read when function names are long - as is the case with tests. Seems its a standard now to use snake case for tests. |
Update naming convention to match official Laravel documentation. These best practices are currently out-of-step with modern Laravel standards. * Laravel [officially changed to snake_case](laravel/laravel#5574) for test case methods in version 8.0. * [Official Laravel documentation](https://laravel.com/docs/10.x/testing) uses snake_case. * [Laracast videos](https://laracasts.com/series/phpunit-testing-in-laravel/episodes/2) use snake_case. * The [previous discussion's](alexeymezenin#28) conclusions on this matter are no longer correct.
Currently:
Camel case prefixed with test.
testGuestCannotSeeArticle()
Proposed:
Descriptive names delimited by underscore
Example:
Reasoning:
Laravel's own tutorials don't even follow the camel case standard.
https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/2
https://laracasts.com/series/phpunit-testing-in-laravel/episodes/2 (This one describes both but shows why underscored version is preferred in Laravel)
The text was updated successfully, but these errors were encountered: