Avoiding Copy errors in Test::Unit (PATCH to Test::Unit::TestCase)

I use Test::Unit a lot, and a lot of the times I create a new test by
taking an old test, copy that to a new file and start modifying
it. The problem is that I sometimes forget to change the class name.

When this happens, tests still work but one class of tests has
silently been discarded.

A colleague, Martin Davis, came up with this simple, short monkeypatch
to hook onto method_added to check for this condition. It works very
well. I think this would be a great addition to Test::Unit::TestCase
in test/unit/testcase.rb

Until then, here’s a little file you can load/require:

On Jan 18, 8:14 am, “R. Bernstein” [email protected] wrote:

in test/unit/testcase.rb

Until then, here’s a little file you can load/require:

test_helper.rb

I like it. However, I should point out that you’ll already get a
warning about redefined methods if you have a setup or teardown method
in any dup’d classes. That’s assuming you’re running your tests with -
w, which of course you are. :slight_smile:

Still, I think it’s a worthy addition.

Regards,

Dan