# Testcase order

**URL:** <https://www.ruby-forum.com/t/testcase-order/134298>\
**Category:** Ruby\
**Created:** [April 9, 2008, 5:18pm UTC](https://www.ruby-forum.com/t/testcase-order/134298 "2008-04-09T17:18:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [April 9, 2008, 5:18pm UTC](https://www.ruby-forum.com/t/testcase-order/134298/1 "2008-04-09T17:18:06Z")

</div>

I’m trying to run different testcases in a file:  
require ‘testcases/dopTest’  
require ‘testcases/bipTest’  
require ‘testcases/canTest’

But when I run it the order is not as I wrote it. First it’s run bipTest  
and the last one dopTest.

How can I sort the order I want?

Thanks.

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [April 9, 2008, 5:32pm UTC](https://www.ruby-forum.com/t/testcase-order/134298/2 "2008-04-09T17:32:01Z")

</div>

On Wed, Apr 9, 2008 at 10:18 AM, Mario R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to run different testcases in a file:  
> require ‘testcases/dopTest’  
> require ‘testcases/bipTest’  
> require ‘testcases/canTest’
> 
> But when I run it the order is not as I wrote it. First it’s run bipTest  
> and the last one dopTest.
> 
> How can I sort the order I want?

Name them in alphabetical order.

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [April 9, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/testcase-order/134298/3 "2008-04-09T17:34:36Z")

</div>

So it’s impossible to run the testcases in the ‘require’ order

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [April 9, 2008, 6:04pm UTC](https://www.ruby-forum.com/t/testcase-order/134298/4 "2008-04-09T18:04:35Z")

</div>

Because I’m running testcases that need the result of another one so  
must be run first.

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [April 9, 2008, 5:59pm UTC](https://www.ruby-forum.com/t/testcase-order/134298/5 "2008-04-09T17:59:45Z")

</div>

On 09/04/2008, Mario R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So it’s impossible to run the testcases in the ‘require’ order

Each of your test should be independent from the other tests.  
Why do you want to run them in a specific order?

-Thomas

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [April 10, 2008, 3:07am UTC](https://www.ruby-forum.com/t/testcase-order/134298/6 "2008-04-10T03:07:47Z")

</div>

On Apr 9, 2008, at 09:04 , Mario R. wrote:

> Because I’m running testcases that need the result of another one so  
> must be run first.

Don’t do that. You don’t want your testcases coupled to each other.  
really. Refactor your tests and decouple them from each other and  
you’ll be much much happier in the long run.

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [April 10, 2008, 3:10am UTC](https://www.ruby-forum.com/t/testcase-order/134298/7 "2008-04-10T03:10:09Z")

</div>

> Because I’m running testcases that need the result of another one so  
> must be run first.

Testcases should run in issolation. One testcase should not be  
dependent on another.
