Opened 10 years ago
Closed 7 years ago
#6009 closed enhancement (maybelater)
Share fixtures across unit tests where appropriate
Reported by: | boonebgorges | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | trac-tidy-2018 |
Cc: |
Description
There are a few places where our unit tests could benefit hugely from sharing fixtures (ie the dummy data) across a series of tests. Take the suggestions
group, for instance: these tests create a bunch of data during each setUp()
, but the data is the same between tests, and is not modified during the tests. So it's safe to share it, and shave a minute or more off of the running time of our suite.
Sharing fixtures should generally be done with caution, but when the tests are testing only *get* functionality, it should be safe.
Change History (11)
#10
@
7 years ago
- Keywords trac-tidy-2018 added
We're closing this ticket because it has not received any contribution or comments for at least two years. We have decided that it is better to close tickets that are good ideas, which have not gotten (or are unlikely to get) contributions, rather than keep things open indefinitely. This will help us share a more realistic roadmap for BuddyPress with you.
Everyone very much appreciates the time and effort that you spent sharing your idea with us. On behalf of the entire BuddyPress team, thank you.
If you feel strongly that this enhancement should still be added to BuddyPress, and you are able to contribute effort towards it, we encourage you to re-open the ticket, or start a discussion about it in our Slack channel. Please consider that time has proven that good ideas without contributions do not get built.
For more information, see https://bpdevel.wordpress.com/2018/01/21/our-awaiting-contributions-milestone-contains/
or find us on Slack, in the #buddypress channel: https://make.wordpress.org/chat/
There are some complications to making
setUpBeforeClass()
work in our suite. This method (andtearDownAfterClass()
must be called statically. This means that they must also call all testcase and factory methods statically. So the relevant methods will have to be defined as static. This in itself is not too big a deal, butcreate_user()
in particular causes problems, because when static, a new factory will have to be defined for each call; and when that happens, theWP_UnitTest_Generator_Sequence
objects are not persistent.For this reason,
create_user()
should be removed, and we should move that logic into our ownBP_UnitTest_Factory_For_User
which will extend the WP version to do our specific BP work. This has the added benefit of greater consistency in our tests.