[wp-trac] [WordPress Trac] #29827: Leftover taxonomies break later tests

WordPress Trac noreply at wordpress.org
Fri Oct 10 13:42:25 UTC 2014


#29827: Leftover taxonomies break later tests
------------------------------+---------------------------
 Reporter:  boonebgorges      |       Owner:  boonebgorges
     Type:  defect (bug)      |      Status:  accepted
 Priority:  normal            |   Milestone:  4.1
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  2nd-opinion       |     Focuses:
------------------------------+---------------------------

Comment (by boonebgorges):

 > Moving everything to tearDown() will probably solve the problem, but I
 want to test this with a skeleton project.

 On further thought, this is pretty obviously not true (that's what I get
 for posting when I roll out of bed). 'init' is fired just once, before all
 the tests are run. It's not going to matter when our testcase tears
 everything down - as soon as it's done, everything run at 'init' is going
 to get reset.

 In theory, each test should be running with a totally clean slate. If we
 could roll back everything that's touched on 'init' and then refire the
 action before each test, that would actually be ideal. And with some work,
 we could probably make this work for WP itself, since we're aware of all
 the stuff that gets touched during our own bootstrap. This is not the case
 for other plugins - they may be setting globals etc that WP can't know
 about. So, to some extent, tasks related to cleanup (and re-setup) must of
 necessity be left to plugin test suites. This suggests that this is
 largely a developer education issue.

 That being said, if there were a way for our suite to be a little more
 generous to devs, I'd be willing to look at it. Let's say, for instance,
 that `reset_post_types()` and `reset_taxonomies()` only ran when the WP
 core tests were being run. Maybe, say, we'd detect whether a test class
 has `WP_UnitTestCase` (or `WP_XMLRPC_UnitTestCase` or
 `WP_Ajax_UnitTestCase` - in other words, a core testcase) as a *direct*
 parent before resetting these globals; tests that have core testcases as
 further ancestors (like `BP_UnitTestCase`
 https://buddypress.trac.wordpress.org/browser/tags/2.1.1/tests/phpunit/includes/testcase.php)
 would not. This is less than ideal if we're trying to force devs to "do
 the right thing", but it will cause less breakage for third parties.

 danielbachhuber, as one of the intrepid souls extending the core tests in
 this way, do you have thoughts on the above?

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


More information about the wp-trac mailing list