# Functional testing with different data sets

**URL:** <https://www.ruby-forum.com/t/functional-testing-with-different-data-sets/174369>\
**Category:** Rails\
**Created:** [August 25, 2009, 8:22pm UTC](https://www.ruby-forum.com/t/functional-testing-with-different-data-sets/174369 "2009-08-25T20:22:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [August 25, 2009, 8:22pm UTC](https://www.ruby-forum.com/t/functional-testing-with-different-data-sets/174369/1 "2009-08-25T20:22:34Z")

</div>

Hello,  
I just ran into a bug in my application in which the behavior differed  
depending on whether there was a single element in a particular table  
or multiple elements in the table. Right after I fixed the bug, I  
thought to myself, “I wonder how I could have structured a functional  
test to detect this?”

For my simple application, I am perfectly happy to use fixtures and  
ActionController::TestCase. I have a fixture with multiple records in  
it. If I wanted to test my application with a single record, and then  
test it again with multiple records, how could I do that?

Any thoughts?

–wpd

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [August 26, 2009, 3:30am UTC](https://www.ruby-forum.com/t/functional-testing-with-different-data-sets/174369/2 "2009-08-26T03:30:24Z")

</div>

Hi Patrick,

On Tue, 2009-08-25 at 13:38 -0400, Patrick D. wrote:

> test it again with multiple records, how could I do that?  
> Fixtures are not the only way to load your test database. You can do  
> whatever you want along the lines of db prep in your individual test  
> methods.

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [August 26, 2009, 6:23am UTC](https://www.ruby-forum.com/t/functional-testing-with-different-data-sets/174369/3 "2009-08-26T06:23:04Z")

</div>

You are describing different test cases.

In most of my applications, I test how the application works when  
there are 0, 1 or \>1 records for a given scenario.  
Those are three separate tests in my application. Fixtures/factories  
are just used to setup the conditions for the test.

Eric

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [August 26, 2009, 9:52am UTC](https://www.ruby-forum.com/t/functional-testing-with-different-data-sets/174369/4 "2009-08-26T09:52:02Z")

</div>

2009/8/26 E. Litwin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> You are describing different test cases.
> 
> In most of my applications, I test how the application works when  
> there are 0, 1 or \>1 records for a given scenario.  
> Those are three separate tests in my application. Fixtures/factories  
> are just used to setup the conditions for the test.

I think the OP understands that, the question is how to use fixtures  
to load different numbers of records to the table for different tests.

Colin
