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.
- 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 ???
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.
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
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.
Hi,
In [email protected]
“Re: No tests were specified errror” on Fri, 29 Jul 2011 20:05:44
+0900,
Robert K. [email protected] 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,