[wp-trac] [WordPress Trac] #53119: Tests: introduce naming conventions for data providers and use named test cases
WordPress Trac
noreply at wordpress.org
Fri Apr 30 18:53:30 UTC 2021
#53119: Tests: introduce naming conventions for data providers and use named test
cases
------------------------------+------------------------------
Reporter: jrf | Owner: (none)
Type: task (blessed) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: | Focuses: docs
------------------------------+------------------------------
Comment (by pbiron):
If any given data provider could only be used for 1 test, then I would
completely agree that having the provider immediately follow it's test.
But since the proposal recognizes that a given provider ''could'' be used
for more than one test then it's **not** guaranteed that a test's provider
will **always** immediately follow it, so folks will still have to "jump
around" some times, which adds a certain amount of "cognitive effort" in
figuring out "is this one of those times?".
Also, I can't remember if the following has come up in tests I've
written/contributed to for core, but it has in test suites for plugins
I've written:
* At time ''T'', I write a test and it's provider (in addition to some
other tests that do **not** use this provider).
* At time ''T + 1'', I add a couple of other tests that are "related" to
one another (after all the existing tests)
* At time ''T + 2'', I realize that the provider already in the class is
appropriate for the "related" tests I added at time ''T + 1'', so I remove
those tests and add their "data" to the provider
Under the proposal as written, a contributor would have to remember to
them move the time ''T + 1'' tests to be after the time ''T'', which can
make for "messy" patches that require a high level of "cognitive effort"
to realize **exactly** what is being changed.
So, for test suites for my own plugins, I adopted the convention to always
put providers at the end of the class.
I'm not wedded to having that all data providers at the end, it's just a
suggestion based on my own experience.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53119#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list