Hi,
I''ve been having problems getting my unit tests to run together, as
data
left over from a previous test is causing problems when trying to delete
data from a related table in another test.
Am I correct in thinking that fixtures loaded within a TestCase subclass
are first removed and then inserted into the test database before every
test method? I''m pretty much 100% this is correct, just want
confirmation.
Initially I was looking for something like teardown that operated on a
TestCase subclass rather than after each test method (like
TestFixtureTeardown in nunit). I could then manually remove my data in
this method once at the end of the TestCase[1]. I''ve searched but as
far as I can tell, this functionality doesn''t exist in test/unit or the
Rails additions.
[1] I realise I could remove the data in teardown but this means that
the data gets removed manually after each test method and then
automatically before the next method is run.
Finally, I looked at use_transactional_fixtures. I thought that this
would start a transaction before every test method and roll it back at
the end, therefore leaving me with an empty database at the end of a
TestCase subclass. On testing, this isn''t the case. In fact, the
Transactional Fixtures example from the Rails book (p177) and rails docs
[2] both appear not to work in my situation. Or, rather, they both pass
the tests regardless of whether I state use_transactional_fixtures or not.
I''m using mysql 4.1.8 on WinXp Pro and all of my tables in the test
database are InnoDB format. Using latest version of Rails
I''d love some light shed on the problems I am seeing and whether
it''s
(probably) just a mis-understanding on my part.
Thanks in advance,
Chris
[2] http://ar.rubyonrails.com/classes/Fixtures.html