Fixtures getting a little hard to manage

I have lots of tests which rely on fixtures being a particular state in
order to pass. For example, one test checks that a User object can have
no
more than 3 associated ‘Page’ objects at a time. That’s a simple example
but
I have more complicated tests too. The problem is I sometimes add a
fixture
without realising it’ll affect the tests and everything blows up.

I’ve taken to creating the a specific state for each test that needs
one,
i.e. before I assert anything, I’ll create new objects from scratch so I
don’t have to use fixtures. This is fine for simple tests but gets
unwieldy
when I’m testing associations between multiple objects.

Just wondering how other people manage situations like this?
alan

Hello Alan,

2006/7/13, Alan B. [email protected]:

I’ve taken to creating the a specific state for each test that needs one,
i.e. before I assert anything, I’ll create new objects from scratch so I
don’t have to use fixtures. This is fine for simple tests but gets unwieldy
when I’m testing associations between multiple objects.

I am doing that too now. I have a set of basic objects in my fixtures
which I reuse in #setup, users and accounts for example. Other
objects I will create on the fly.

If your tests are hard to write, this is usually a hint that there is
something missing in your models / associations to make things easier.

Hope that helps !