Closed (fixed)
Project:
SimpleTest
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
28 Mar 2008 at 02:23 UTC
Updated:
4 May 2008 at 09:51 UTC
This comes courtesy of dmitri...paraphrased:
Now that we're doing testing via table prefixes rather than the actual database where SimpleTest module is installed, it seems a little silly to have a bunch of clean-up routines that delete nodes/users/roles/etc. created during the test, no?
A side benefit is this would probably help the tests run marginally faster, too.
Comments
Comment #1
boombatower commentedYea, I noticed that yesterday when I was trying to fix the db_prefix stuff. I figured I would wait to see if I can get the db_prefix stuff working before attempting to remove code that it makes pointless.
http://drupal.org/node/239565
Comment #2
webchickThat sounds reasonable. ;)
Comment #3
dlangevin commentedI haven't read through everything posted here, but having a known state of the database before running any test is usually a desirable thing. I think that it would be very helpful to have database fixtures for these tests. This is the way it is implemented in Ruby on Rails and it is very helpful to know that you have certain records in the DB with known IDs that are created before tests are run and destroyed after they have completed.
Knowing that these records exist, how many there are, and what their IDs are can be very helpful in writing tests from my experience.
I would propose the following.
1 - All modules can have their own "fixtures" folder (which would live under tests)
2 - Fixtures would have a known format (like XML, YAML, JSON, or whatever people like best)
3 - There would be an empty method defined in DrupalTestCase called createFixtures(), which could be defined in any test class to load the fixtures that are necessary for that test. This method would be added to DrupalTestCase::setUp() so it is called by default before every test, or we could put it in the constructor to be called once.
4 - A method called loadFixture($fixtureName) would load a file located at tests/fixtures/$fixtureName.(xml/yaml/json). The data would then be loaded into the database. This method would be called within createFixtures().
5 - A method called deleteFixtures() would truncate all tables that had fixtures loaded (these tables would be saved as a private array)
Thoughts about this approach? Has it been discussed before at all?
Comment #4
boombatower commentedJust to fill you in on what this is about. The current setup as of chx's patch installs drupal once per test function. This is done in the
setUpmethod of theDrupalTestCaseand destroyed intearDown. In other words a fresh install is placed in a set of prefixed tables and the test is run off that.The patch had a few issues, but those seemed to be resolved.
Because of this functionality the tests can count on the default install of drupal and related data structures.
I'm thinking this alleviates the need for fixtures, but I'm not sure if I fully understand the data that would be stored in fixtures.
I appreciate your thoughts.
Comment #5
chx commentedComment #6
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.