[wp-trac] [WordPress Trac] #41658: Renaming unit test files with underscore in their names.

WordPress Trac noreply at wordpress.org
Fri Aug 18 00:42:51 UTC 2017


#41658: Renaming unit test files with underscore in their names.
------------------------------+------------------
 Reporter:  stephdau          |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  4.9
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------

Comment (by netweb):

 Replying to [comment:5 pento]:
 > There doesn't appear to be any particular standard for naming test
 files, but it looks like camelCase is the most common, so I'm cool with
 using that.

 There is now: https://make.wordpress.org/core/handbook/testing/automated-
 testing/phpunit/#naming

 These new docs changes are based on "PHP Unit testing" #coe chats from ~18
 months ago
 * https://make.wordpress.org/core/2016/02/12/php-unit-test-discussion-
 feb-12-recap/
 * https://wordpress.slack.com/archives/C02RQBWTW/p1456515743002360

 > • Writing Tests - Naming
 > • Tests should be organized in such a way that they’re easy to find and
 easy to run in isolation.
 > • Generally the test file path has taken the form
 `/tests/phpunit/tests/{component}/{functionInCamelCase}.php`
 > • Generally a file’s test class has taken the form
 `Tests_{Component}_{FunctionInCamelCase}`
 > • Test method names should take the format
 `test_{{description_of_what_is_expected}}`. For example,
 `test_termmeta_cache_should_be_primed_by_default`.
 > • Sometimes it’s handy to have things like
 `/tests/phpunit/tests/query/orderby.php`, which is not about a function
 name but instead about a part of the query infrastructure

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41658#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list