# Is this a unit/test bug?

**URL:** <https://www.ruby-forum.com/t/is-this-a-unit-test-bug/173435>\
**Category:** Ruby\
**Created:** [August 8, 2009, 9:24pm UTC](https://www.ruby-forum.com/t/is-this-a-unit-test-bug/173435 "2009-08-08T21:24:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [August 8, 2009, 9:24pm UTC](https://www.ruby-forum.com/t/is-this-a-unit-test-bug/173435/1 "2009-08-08T21:24:27Z")

</div>

C:\dev\ruby\ties\>ruby  
C:\dev\ruby\ties\test\functional\store\_controller\_test.rb  
-ntest\_gives\_single\_discount

# this one works ^^^^^^

# this one fails vvvvvv

C:\dev\ruby\ties\>ruby  
C:\dev\ruby\ties\test\functional\store\_controller\_test.rb  
–testcase=test\_gives\_single\_discount  
C:/dev/ruby/ties/test/functional/…/test\_helper  
Loaded suite C:/dev/ruby/ties/test/functional/store\_controller\_test  
Started

Finished in 0.0 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

but --testcase is supposed to be a test pattern…anybody know what’s  
going on here? I’m thinking this is a bug.  
-r

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [August 8, 2009, 11:10pm UTC](https://www.ruby-forum.com/t/is-this-a-unit-test-bug/173435/2 "2009-08-08T23:10:34Z")

</div>

On 8/8/09, Roger P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –testcase=test\_gives\_single\_discount  
> C:/dev/ruby/ties/test/functional/…/test\_helper  
> Loaded suite C:/dev/ruby/ties/test/functional/store\_controller\_test  
> Started
> 
> Finished in 0.0 seconds.
> 
> 0 tests, 0 assertions, 0 failures, 0 errors
> 
> but --testcase is supposed to be a test pattern…anybody know what’s  
> going on here? I’m thinking this is a bug.

As far as I know, the -n (or --name) parameter to test/unit gives the  
name of a test method (or methods) to be run. The -t (or --testcase)  
parameter gives the name of a test class. So, it looks like the second  
command didn’t do what you want because there’s no class named  
test\_gives\_single\_discount.

PS: if you want to use a pattern (regex) in names used by -n and -t, I  
think you have to enclose the name in slashes. (eg: -n  
/test\_gives\_single\_discount/ )

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [August 9, 2009, 5:51am UTC](https://www.ruby-forum.com/t/is-this-a-unit-test-bug/173435/3 "2009-08-09T05:51:30Z")

</div>

On Aug 8, 2009, at 12:24 , Roger P. wrote:

I cleaned it up for you:

> but --testcase is supposed to be a test pattern…anybody know what’s  
> going on here? I’m thinking this is a bug.

no, --testcase MAY take a pattern, and you didn’t provide one  
(patterns start with “/” like default regexps). But that isn’t your  
problem. This should shed some light:

502 % ruby -rtest/unit -e 0 – --help  
Test::Unit automatic runner.  
Usage: -e [options] [-- untouched arguments]

…  
-n, --name=NAME Runs tests matching NAME.  
(patterns may be used).  
-t, --testcase=TESTCASE Runs tests in TestCases matching  
TESTCASE.  
(patterns may be used).  
…
