# No tests were specified errror

**URL:** <https://www.ruby-forum.com/t/no-tests-were-specified-errror/210054>\
**Category:** Ruby\
**Created:** [July 29, 2011, 10:20am UTC](https://www.ruby-forum.com/t/no-tests-were-specified-errror/210054 "2011-07-29T10:20:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [July 29, 2011, 10:20am UTC](https://www.ruby-forum.com/t/no-tests-were-specified-errror/210054/1 "2011-07-29T10:20:13Z")

</div>

Hi all,

I am new to ruby and so i am facing this silly issue.

I have a BaseClass which i have inherited from test::Unit::Testcase,  
Inside that i only have setup and teardown method. Now there is another  
class DemoTest which i have inherited from BaseClass as shown below

BaseClass.rb inside Test folder  
require ‘test/unit’  
require ‘rubygems’  
class BaseClass \< Test::Unit::TestCase  
def setup  
puts “setup called”  
end

def teardown  
puts “teardown called”  
end  
end

DemoTest.rb inside Test Folder  
require ‘Test/BaseClass’  
require ‘test/unit’  
require ‘rubygems’

class DemoTest \< BaseClass

def test\_first  
puts “first”  
end

def test\_second  
puts “second”  
end

end

Now when i run the DemoTest.rb it says something like this.

1. Failure:  
default\_test(BaseClass) [C:/Documents and  
Settings/gshah/workspace/Framework/Test/DemoTest.rb:27]:  
No tests were specified.

3 tests, 1 assertions, 1 failures, 0 errors

I am not able to understand why it is showing that No test were  
specified.

And why it is showing me that there were 3 test while there is only two  
tests ???

---

<div class="post-metadata">

**Author:** ![gaurang033](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5f8ce5/32.png) [@gaurang033](https://www.ruby-forum.com/u/gaurang033)\
**Post date:** [July 29, 2011, 10:48am UTC](https://www.ruby-forum.com/t/no-tests-were-specified-errror/210054/2 "2011-07-29T10:48:54Z")

</div>

It’s because it’s trying to run all test cases in BaseClass and in  
DemoTest (since the default behaviour is to find all classes which are  
subclasses of Test::Unit::TestCase, and run those)

If someone can explain how to mark BaseClass as ‘not for testing’ then  
I’d like to know that as well, as I had the same problem too.

My workaround was to define a method test\_dummy in BaseClass which does  
nothing (or just assert true), but I expect there’s a better way.

---

<div class="post-metadata">

**Author:** ![gaurang033](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5f8ce5/32.png) [@gaurang033](https://www.ruby-forum.com/u/gaurang033)\
**Post date:** [July 29, 2011, 1:05pm UTC](https://www.ruby-forum.com/t/no-tests-were-specified-errror/210054/3 "2011-07-29T13:05:42Z")

</div>

Brian C. wrote in post #1013695:

> If someone can explain how to mark BaseClass as ‘not for testing’ then  
> I’d like to know that as well, as I had the same problem too.

+1

> My workaround was to define a method test\_dummy in BaseClass which does  
> nothing (or just assert true), but I expect there’s a better way.

Another workaround might be to replace BaseClass with a module which is  
included in DemoTest which then directly inherits Test::Unit::TestCase.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![gaurang033](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5f8ce5/32.png) [@gaurang033](https://www.ruby-forum.com/u/gaurang033)\
**Post date:** [July 29, 2011, 1:48pm UTC](https://www.ruby-forum.com/t/no-tests-were-specified-errror/210054/4 "2011-07-29T13:48:42Z")

</div>

Robert K. wrote in post #1013718:

> Brian C. wrote in post #1013695:
> 
> > If someone can explain how to mark BaseClass as ‘not for testing’ then  
> > I’d like to know that as well, as I had the same problem too.
> 
> +1
> 
> > My workaround was to define a method test\_dummy in BaseClass which does  
> > nothing (or just assert true), but I expect there’s a better way.
> 
> Another workaround might be to replace BaseClass with a module which is  
> included in DemoTest which then directly inherits Test::Unit::TestCase.
> 
> Kind regards
> 
> robert

Thanks robert,  
I did the same thing but then the problem is another method like  
startup, shutdown or cleanup is not being called.

---

<div class="post-metadata">

**Author:** ![gaurang033](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5f8ce5/32.png) [@gaurang033](https://www.ruby-forum.com/u/gaurang033)\
**Post date:** [July 30, 2011, 12:05pm UTC](https://www.ruby-forum.com/t/no-tests-were-specified-errror/210054/5 "2011-07-30T12:05:54Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: No tests were specified errror” on Fri, 29 Jul 2011 20:05:44  
+0900,  
Robert K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Brian C. wrote in post #1013695:
> 
> > If someone can explain how to mark BaseClass as ‘not for testing’ then  
> > I’d like to know that as well, as I had the same problem too.
> 
> +1

Implement it as a module not class. To share method  
implementations, a module and ‘include’ are used in Ruby  
way. To implement the same category objects, a class and  
inheritance are used in Ruby way. So test-unit 2.x use a  
module and ‘include’ for ‘not for testing, just for  
sharing’.  
(“Ruby way” is one of the important keywords in test-unit  
API.)

> > My workaround was to define a method test\_dummy in BaseClass which does  
> > nothing (or just assert true), but I expect there’s a better way.
> 
> Another workaround might be to replace BaseClass with a module which is  
> included in DemoTest which then directly inherits Test::Unit::TestCase.

So it’s not workaround. It’s a right (Ruby and test-unit) way. 🙂

Thanks,
