# Unit Tests

**URL:** <https://www.ruby-forum.com/t/unit-tests/104954>\
**Category:** Rails\
**Created:** [May 24, 2007, 10:01am UTC](https://www.ruby-forum.com/t/unit-tests/104954 "2007-05-24T10:01:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [May 24, 2007, 10:01am UTC](https://www.ruby-forum.com/t/unit-tests/104954/1 "2007-05-24T10:01:24Z")

</div>

Hi,  
If you have (say) 50 unit tests how do you run them all and check that  
there are no failures.  
I have a script that runs all the tests but it is difficult to spot  
failures in the mass of output…

Giorgio

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [May 24, 2007, 10:10am UTC](https://www.ruby-forum.com/t/unit-tests/104954/2 "2007-05-24T10:10:39Z")

</div>

Just plain ‘rake’ should run all your tests and count up the  
successes/failures

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [May 24, 2007, 10:48am UTC](https://www.ruby-forum.com/t/unit-tests/104954/3 "2007-05-24T10:48:43Z")

</div>

For running all test files, run ‘rake’ command. For more specific tests:

rake test # Test all units and functionals  
rake test:functionals # Run the functional tests in  
test/functional  
rake test:integration # Run the integration tests in  
test/integration  
rake test:plugins # Run the plugin tests in  
vendor/plugins/\*\*/test (or specify with PLUGIN=name)  
rake test:recent # Test recent changes  
rake test:uncommitted # Test changes since last checkin (only  
Subversion)  
rake test:units # Run the unit tests in test/unit

You can see available rake test tasks, by running ‘rake -T test’ from  
your project directory.

You can also run a test file with ruby:

ruby test/unit/model\_test.rb

Or even just a test method by passing it’s name to -n switch:

ruby test/unit/model\_test.rb -n test\_method

HTH

- H

On 5/24/07, giorgio [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> >

–  
Husein C.  
Yucca Intelligence Development

> **[قفل دیجیتال | قفل هوشمند | قفل الکترونیکی کره‌ای | یوکا](https://yuccahq.com/)**
>
> نگران قیمت بی‌ثبات هستی؟ از تخصصی‌ترین برند قفل هوشمند با اطمینان و تضمین قیمت خرید کن! معتبرترین برند کره جنوبی:قفل الکترونیکی یوکا همین الان تماس بگیرید و از تخفیف‌های شگفت‌انگیز ما استفاده کنید.

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [May 24, 2007, 10:58am UTC](https://www.ruby-forum.com/t/unit-tests/104954/4 "2007-05-24T10:58:46Z")

</div>

Thanks that is exactly what I needed.  
I was sure there must be a better way than a script!  
G

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [May 24, 2007, 12:01pm UTC](https://www.ruby-forum.com/t/unit-tests/104954/5 "2007-05-24T12:01:02Z")

</div>

On Thu, May 24, 2007 at 07:59:57AM -0000, giorgio wrote:

> If you have (say) 50 unit tests how do you run them all and check that  
> there are no failures.  
> I have a script that runs all the tests but it is difficult to spot  
> failures in the mass of output…

A tip if you want nicely colored and formatted output:

```
    gem install turn
    gem install facets

```

And then in test\_helper.rb:

```
    require 'turn'

```

It is somewhat more verbose than the default test/unit output, so it’s a  
matter of taste. I’m not sure the coloring works on windows though, the  
formatting is still good.

–  
Cheers,

- Jacob A.
