I''m using Test::Rails from ZenTest. I did an abstract(?) class that inherits from Test::Rails::TestCase and I wanted to define some general test there to be inherited by my testcases. The problem is that when I run my testcase the tests defined in the avstract class are executed twice: first for the class inheriting from it and then again for the abstract class. To be more clear: MyTestCase < MyAbstracyClass < Test::Rails::TestCase Supposing there is one test defined in MyTestCase and two defined in MyAbstractClass the test executed will be 5. How can I skip the tests in the abstract class? Till now I resolved setting the following code at the beginning of each test: return if self.class == MyAbstracyClass ...but the test are still be counted... Any idea? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 7 Nov 2007, at 10:38, Emanuele Ricci wrote:> > MyTestCase < MyAbstracyClass < Test::Rails::TestCase > > Supposing there is one test defined in MyTestCase and two defined in > MyAbstractClass the test executed will be 5. > > How can I skip the tests in the abstract class? > Till now I resolved setting the following code at the beginning of > each > test: > return if self.class == MyAbstracyClass > ...but the test are still be counted... > > Any idea?I don''t know how zen test differs from the Test::Unit stuff that comes as standard with ruby, but we had a similar situation with that and ended up putting the common stuff in a module which we included where appropriate. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 7, 2007 9:46 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 7 Nov 2007, at 10:38, Emanuele Ricci wrote: > > > > > MyTestCase < MyAbstracyClass < Test::Rails::TestCase > > > > Supposing there is one test defined in MyTestCase and two defined in > > MyAbstractClass the test executed will be 5. > > > > How can I skip the tests in the abstract class? > > Till now I resolved setting the following code at the beginning of > > each > > test: > > return if self.class == MyAbstracyClass > > ...but the test are still be counted... > > > > Any idea? > I don''t know how zen test differs from the Test::Unit stuff that comes > as standard with ruby, but > we had a similar situation with that and ended up putting the common > stuff in a module which we included where appropriate.I''d use mixins too, but if it''s too late: require ''active_support'' require ''test/unit'' class << Test::Unit::TestCase def abstract @abstract = true end def suite_with_abstract if @abstract Test::Unit::TestSuite.new else suite_without_abstract end end alias_method_chain :suite, :abstract end class AbstractTests < Test::Unit::TestCase abstract def test_a assert true end end class RealTests < AbstractTests end class MoreRealTests < AbstractTests end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sounds great if it works, but it is not clear to me where to put the following code: require ''active_support'' require ''test/unit'' class << Test::Unit::TestCase def abstract @abstract = true end def suite_with_abstract if @abstract Test::Unit::TestSuite.new else suite_without_abstract end end alias_method_chain :suite, :abstract end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
It works indeed, thank you very much George. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---