Doug Livesey
2006-Jul-26 16:04 UTC
[Rails] fixtures not loading when running rake test - ok other times
Hallo -- I have the most bizzare problem. I have a test called PropertyTest that runs absolutely fine. Even if I totally clear the test database before running it, it happily scoots off, loads all necessary fixtures, runs & passes all tests. My problem arises when I run rake test:units. Then, all other tests pass fine, but this one starts failing as if the fixture data simply hasn''t loaded (counts of 0 where 3 were expected, etc.). Another reason I suspect it is fixture related is that I was referring to the fixtures with the test shorthand "properties(:secondary_school)" (where secondary_school is the name of one of my Property fixtures) -- again, this ran fine on its own, but threw errors (not fails, errors) when I ran the test with all the other unit tests. Changing the test code to explicitly find any property fixtures I needed from the database fixed this, although I still have the fails where data apparently does not exist. Has anyone else come across this? & knows a fix for it? Obviously I could ignore it, as the test runs fine individually, but I hate not having a cleanly passing test suite -- it obviously becomes less effective when you have to keep track of which tests you aren''t expecting to pass under certain circumstances. If anyone can help, I''d be massively grateful. Cheers, Doug. -- Posted via http://www.ruby-forum.com/.
Doug Livesey
2006-Jul-26 16:11 UTC
[Rails] Re: fixtures not loading when running rake test - ok other t
Hi -- I''ve not solved the problem, but I do have a horrible hack fix that is working for the moment. I''ve changed the order the test is called in by changing test''s name from PropertyTest to ZPropertyTest. Why this has worked, I''m not sure, as (like I said) I can''t replicate the failures by clearing the test database & running the test on its own, so I don''t beleive it can be a missing fixture declaration or anything. Naturally, I would still appreciate any help anyone can offer on this, as I can see a future where I have to name tests to fudge their calling order, which is far from ideal. Cheers, Doug. -- Posted via http://www.ruby-forum.com/.