[wp-trac] [WordPress Trac] #35199: WP_UnitTest_Generator_Sequence is generating incorrect sequences

WordPress Trac noreply at wordpress.org
Thu Dec 24 16:05:04 UTC 2015


#35199: WP_UnitTest_Generator_Sequence is generating incorrect sequences
------------------------------+------------------
 Reporter:  OddOneOut         |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  4.5
Component:  Build/Test Tools  |     Version:  4.4
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------
Changes (by boonebgorges):

 * milestone:  Awaiting Review => 4.5


Comment:

 Replying to [comment:3 OddOneOut]:
 > @boonebgorges thanks for your quick reply.
 >
 > Let's say I have a function in my plugin that lists all post titles. If
 I create a test for it, naturally I will create posts using the factory
 before every test (each test has a different number of posts), so that:
 >
 > - Test 1 will assert this output: "Post title list: Post title 1, Post
 title 2"
 > - Test 2 will assert this output: "Post title list: Post title 1, Post
 title 2, Post title 3"
 >
 > Which means for every test the count must be reset.

 It only "must be reset" if you have written tests that assume that the
 incrementor will be reset between tests :)

 All this being said, I think it's worth considering the following:

 1. a method that test methods can use to reset the incrementor.
 2. more consistent use of incrementors within methods (so that a post with
 "Post title 2" will also use the incrementor 2 in all of its other
 properties)

 I do *not* think core tests need to reset the incrementor between tests;
 doing so will make our tests more fragile by causing insert failures when
 a prior test fails to clean up after itself.

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


More information about the wp-trac mailing list