# How to run just one test method in a test case

**URL:** <https://www.ruby-forum.com/t/how-to-run-just-one-test-method-in-a-test-case/96795>\
**Category:** Ruby\
**Created:** [January 24, 2006, 9:04pm UTC](https://www.ruby-forum.com/t/how-to-run-just-one-test-method-in-a-test-case/96795 "2006-01-24T21:04:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicknameoptional](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@nicknameoptional](https://www.ruby-forum.com/u/nicknameoptional)\
**Post date:** [January 24, 2006, 9:04pm UTC](https://www.ruby-forum.com/t/how-to-run-just-one-test-method-in-a-test-case/96795/1 "2006-01-24T21:04:38Z")

</div>

for example, I have a testcase class, which has test\_1, test2, test3  
… methods. how to run just one of the test, like test\_1? Thanks

---

<div class="post-metadata">

**Author:** ![nicknameoptional](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@nicknameoptional](https://www.ruby-forum.com/u/nicknameoptional)\
**Post date:** [January 24, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/how-to-run-just-one-test-method-in-a-test-case/96795/2 "2006-01-24T21:19:47Z")

</div>

On Wed, Jan 25, 2006 at 05:03:13AM +0900, nicknameoptional wrote:

> for example, I have a testcase class, which has test\_1, test2, test3  
> … methods. how to run just one of the test, like test\_1? Thanks

The -n option.

You can run a test by name

e.g.

ruby tc\_foo.rb -n test\_foo\_1

or by pattern match

ruby tc\_foo.rb -n /foo\_2/

marcel

---

<div class="post-metadata">

**Author:** ![nicknameoptional](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@nicknameoptional](https://www.ruby-forum.com/u/nicknameoptional)\
**Post date:** [January 24, 2006, 9:34pm UTC](https://www.ruby-forum.com/t/how-to-run-just-one-test-method-in-a-test-case/96795/3 "2006-01-24T21:34:59Z")

</div>

thanks. should read my rails book more carefully.
