Ryan sez:
I do it all the time. The simple solution is to put a "test_dummy" in
the superclass. Really not hard and a fair tradeoff to have the right
code in the right place.
This has been suggested before to the Watir users. Many of them don't
like the fact that this results in an incorrect test case count.
Quite frankly, I don't really care that they consider it to output an "incorrect" test case count. It works for many of us and is a fair tradeoff. I'd much rather have the requirement removed from test/unit outright, but I didn't design test/unit and I too disagree with requiring it (but! see below!). I however disagree wholly with making test/unit MORE complex under all but the most optimal of returns. I don't think your suggestion matches that requirement esp since it clearly violates the notion of a unit test.
That said, I think your proposal has merit, just not where you want it. I did just poke around a bit more and figgered something out that might be satisfactory for the both of us:
501 % ruby -rtest/unit -e 'class X < Test::Unit::TestCase; end'
Loaded suite -e
Started
F
Finished in 0.005603 seconds.
1) Failure:
default_test(X) [-e:1]:
No tests were specified.
1 tests, 1 assertions, 1 failures, 0 errors
502 % ruby -rtest/unit -e 'class X < Test::Unit::TestCase; def default_test; end; end'
Loaded suite -e
Started
.
Finished in 0.00228 seconds.
1 tests, 0 assertions, 0 failures, 0 errors
YES, it still has an incorrect test count, but it also doesn't have as much "smell" as "test_dummy" in an abstract testcase.
I disagree. As I said before, we need less code, not more. (I do
wholly agree that test/unit needs refactoring, but to make it thinner
not thicker)
My suggestion is only to add a new seam, but i guess that amounts to a
bit of code. But only a bit.
Another reason that i packaged the code as a mod to TestCase directly
is that it makes it easier for people with large test suites to plug it
in. So it is more convenient for Watir users than a subclass.
How is it more convenient?
require 'monkeypatch'
class BlahTest < Test::Unit::TestCase
execute :sequentially
...
end
vs
require 'systemtestcase'
class BlahTest < SystemTestCase
execute :sequentially
...
end
Do you really see either of those as more convenient than the other?
However, I'm not quite sure whether you are saying
a) i (ryan) would prefer to do it a different way
b) i don't want to see this change made to the core test/unit code in
ruby
c) it is a bad idea for anyone to use this mod
I understand (a). I can see your reasons for (b), and actually have
been eager for feedback on whether this might be a good idea or not.
(although i did get some positive noises offline from Nathaniel Talbott
-- the test/unit author). i can see no grounds for (c) -- if this is
your position, please elaborate.
(a) obviously, but on the grounds of (b). I've purposefully not addressed (c) as I think its been addressed (several times) before, but I also agree that it is a bad idea to use the mod.
···
On May 22, 2006, at 11:58 AM, bpettichord@gmail.com wrote:
--
ryand-ruby@zenspider.com - Seattle.rb - Seattle.rb | Home
http://blog.zenspider.com/ - http://rubyforge.org/projects/ruby2c