# Avoiding inserting and removing fixtures in testing

**URL:** <https://www.ruby-forum.com/t/avoiding-inserting-and-removing-fixtures-in-testing/133978>\
**Category:** Rails\
**Created:** [April 6, 2008, 12:36am UTC](https://www.ruby-forum.com/t/avoiding-inserting-and-removing-fixtures-in-testing/133978 "2008-04-06T00:36:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [April 6, 2008, 12:36am UTC](https://www.ruby-forum.com/t/avoiding-inserting-and-removing-fixtures-in-testing/133978/1 "2008-04-06T00:36:55Z")

</div>

I have some testcases that involve many fixtures to perform one or two  
of the tests.

However, the other 10 tests in that testcase don’t rely on those  
fixtures, yet are all the fixtures being loaded in and dropped between  
every test method?

If so, how can I avoid this with out bunching up tests into categories  
like “these need all these fixtures” and “these dont…”

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [April 6, 2008, 10:00am UTC](https://www.ruby-forum.com/t/avoiding-inserting-and-removing-fixtures-in-testing/133978/2 "2008-04-06T10:00:31Z")

</div>

Don’t write your test such that class X has test XSpec or XTest  
instead write tests based on the context of what your testing

ie a Stack element might have 3 test suites

describe EmptyStack do  
describe StackWithElements do  
describe StackIsFull do

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [April 6, 2008, 12:05pm UTC](https://www.ruby-forum.com/t/avoiding-inserting-and-removing-fixtures-in-testing/133978/3 "2008-04-06T12:05:43Z")

</div>

On Apr 5, 11:36 pm, Aryk G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I have some testcases that involve many fixtures to perform one or two  
> of the tests.
> 
> However, the other 10 tests in that testcase don’t rely on those  
> fixtures, yet are all the fixtures being loaded in and dropped between  
> every test method?

If you are using transactional fixtures (it’s the default), then  
fixtures are loaded only once per test run.

Fred
