# Running a specific test in a test file

**URL:** <https://www.ruby-forum.com/t/running-a-specific-test-in-a-test-file/155668>\
**Category:** Ruby\
**Created:** [December 15, 2008, 1:48pm UTC](https://www.ruby-forum.com/t/running-a-specific-test-in-a-test-file/155668 "2008-12-15T13:48:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hunt\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b9e5f3/32.png) [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Post date:** [December 15, 2008, 1:48pm UTC](https://www.ruby-forum.com/t/running-a-specific-test-in-a-test-file/155668/1 "2008-12-15T13:48:21Z")

</div>

I remember there was a way to run a specific test from a test file.

```
ruby test_file.rb

```

Runs the all the tests. How can I select one from this?

Also is there any complete reference on this (which argument the ruby  
command takes when running test files)?

John

---

<div class="post-metadata">

**Author:** ![Hunt\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b9e5f3/32.png) [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Post date:** [December 15, 2008, 2:47pm UTC](https://www.ruby-forum.com/t/running-a-specific-test-in-a-test-file/155668/2 "2008-12-15T14:47:05Z")

</div>

On Mon, Dec 15, 2008 at 7:40 AM, Hunt J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Are you talking about a Ruby on Rails application? If so, try:

$ cd test  
$ ruby unit/\<\>\_test.rb

If you want to run a specific test (that you have defined, say in  
mymodel.rb), you can run

$ ruby unit/mymodel.rb -n test\_min\_is\_less\_than\_max

assuming you want to run the “min is less than max” text, also known as  
“test\_min\_is\_less\_than\_max”.

At least, that’s what works for me 🙂

–wpd
