Re: Re: [Rails-core] Clean Functional Tests

1 view
Skip to first unread message

Chris Roos

unread,
Aug 21, 2006, 8:05:15 AM8/21/06
to Rails Core
* Posting on behalf of James Mead (james...@gmail.com) *

Sounds interesting. I've been doing my own monkey-patching recently
(http://mocha.rubyforge.org/classes/MultipleSetupAndTeardown.html) and
have noticed a couple of other people
(http://www.agilewebdevelopment.com/plugins/testcase_setup_and_teardown_with_blocks
and http://mabs29.googlecode.com/svn/trunk/plugins/active_test/lib/active_test/base.rb)
doing similar things. It would be really good to get support for
multiple setup/teardown methods into the Test::Unit library.

James.

P.S. Apologies if this message is duplicated, I noticed that I sent to
the old list address and am therefore re-sending.

On 8/21/06, Chris Roos <chris...@gmail.com> wrote:
> * Posting on behalf of James Mead (james...@gmail.com) *
>
> Sounds interesting. I've been doing my own monkey-patching recently
> (http://mocha.rubyforge.org/classes/MultipleSetupAndTeardown.html) and
> have noticed a couple of other people
> (http://www.agilewebdevelopment.com/plugins/testcase_setup_and_teardown_with_blocks
> and http://mabs29.googlecode.com/svn/trunk/plugins/active_test/lib/active_test/base.rb)
> doing similar things. It would be really good to get support for
> multiple setup/teardown methods into the Test::Unit library.
>
> James.
>
>
> On 8/19/06, Nathaniel Talbott <ntal...@gmail.com> wrote:
> > On 8/18/06, Keith Morrison <kei...@infused.org> wrote:
> >
> > > You could define a fake test, but then the test and assertion count will
> > > be off.
> >
> > A simple:
> >
> > def default_test
> > end
> >
> > In your abstract test case will prevent the failure, and while you
> > will see an extra test, there will be no assertion inflation.
> >
> > I know that the default_test is pretty much universally hated (Ryan
> > Davis has a colorfully named test method in one of his base classes to
> > prevent it from failing) and I agree that it is/was a bad idea. I'm
> > working on something that I'm hoping will greatly improve the ability
> > for frameworks like Rails to do "frameworky stuff" for testing without
> > completely monkey-patching the testing framework. More details when I
> > have something concrete to show.
> >
> > HTH,
> >
> >
> > --
> > Nathaniel Talbott
> >
> > <:((><
> > _______________________________________________
> > Rails-core mailing list
> > Rails...@lists.rubyonrails.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails-core
> >
>

Jeremy Kemper

unread,
Aug 21, 2006, 3:54:10 PM8/21/06
to rubyonra...@googlegroups.com
On 8/21/06, Chris Roos <chris...@gmail.com> wrote:
* Posting on behalf of James Mead (james...@gmail.com) *

Sounds interesting. I've been doing my own monkey-patching recently

have noticed a couple of other people
(http://www.agilewebdevelopment.com/plugins/testcase_setup_and_teardown_with_blocks
and http://mabs29.googlecode.com/svn/trunk/plugins/active_test/lib/active_test/base.rb)
doing similar things. It would be really good to get support for
multiple setup/teardown methods into the Test::Unit library.


I'd like class methods to declare setup/teardown behavior:

  setup :load_fixtures, :begin_transaction
  teardown :rollback_transaction

# same with teardown
def self.setup(*methods, &block)
  setup_methods.concat(methods)
  setup_methods << block if block_given?
end

# unfortunately difficult to override, have to replace wholesale
def run
  ...
  begin
    #instead of setup
    call_setup_methods
    ...
  ensure
    begin
      #instead of teardown
      call_teardown_methods
    ...
end


jeremy

Jonathan Viney

unread,
Aug 21, 2006, 5:06:20 PM8/21/06
to rubyonra...@googlegroups.com
My plugin allows you to do that. It's a huge hack, but it works for me! As far as I know it is completely backwards compatible.

http://svn.viney.net.nz/things/rails/plugins/testcase_setup_and_teardown_with_blocks

-Jonathan.

Jeremy Kemper

unread,
Aug 21, 2006, 5:17:54 PM8/21/06
to rubyonra...@googlegroups.com
On 8/21/06, Jonathan Viney <jonatha...@gmail.com> wrote:
My plugin allows you to do that. It's a huge hack, but it works for me! As far as I know it is completely backwards compatible.

http://svn.viney.net.nz/things/rails/plugins/testcase_setup_and_teardown_with_blocks

We use the same approach (method_added).  I hope test/unit breaks its run method into more digestible chunks to make this unnecessary.

jeremy
Reply all
Reply to author
Forward
0 new messages