# Testing: 'test "..." do' works but not 'def test...'

**URL:** <https://www.ruby-forum.com/t/testing-test-do-works-but-not-def-test/176094>\
**Category:** Rails\
**Created:** [September 24, 2009, 6:04pm UTC](https://www.ruby-forum.com/t/testing-test-do-works-but-not-def-test/176094 "2009-09-24T18:04:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@drewB](https://www.ruby-forum.com/u/drewB)\
**Post date:** [September 24, 2009, 6:04pm UTC](https://www.ruby-forum.com/t/testing-test-do-works-but-not-def-test/176094/1 "2009-09-24T18:04:42Z")

</div>

I have just encountered a funny situation. I have a number of  
functional and unit cases that are all written with the notation:

def ----

#test case

end

I just created a new model and controller with test cases written in a  
similar format. When I run the test cases, no test are actually run  
(i see, “0 tests, 0 assertions, 0 failures, 0 errors”). If I convert  
to the format:

test “----” do

end

It works. All my old test cases work as expected. As far as I can  
tell everything is set up the same way.

Any idea why this might be happening?

---

<div class="post-metadata">

**Author:** ![drewB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@drewB](https://www.ruby-forum.com/u/drewB)\
**Post date:** [September 24, 2009, 6:30pm UTC](https://www.ruby-forum.com/t/testing-test-do-works-but-not-def-test/176094/2 "2009-09-24T18:30:27Z")

</div>

Quoting drewB [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I just created a new model and controller with test cases written in a  
> similar format. When I run the test cases, no test are actually run  
> (i see, “0 tests, 0 assertions, 0 failures, 0 errors”). If I convert  
> to the format:
> 
> test “----” do
> 
> end

Just to clarify, the first case is actually

def test\_—  
#test case  
end

Methods with the “test\_” prefix are run, others are assumed to be  
supporting  
code.

Jeffrey

---

<div class="post-metadata">

**Author:** ![drewB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@drewB](https://www.ruby-forum.com/u/drewB)\
**Post date:** [September 24, 2009, 6:43pm UTC](https://www.ruby-forum.com/t/testing-test-do-works-but-not-def-test/176094/3 "2009-09-24T18:43:56Z")

</div>

That was it. I didn’t know you had to start with “test.” Thanks so  
much!
