[Pyunit-interest] Re: Pyunit-interest digest, Vol 1 #27 - 1 msg
Brought to you by:
purcell
From: Pieter N. <pi...@na...> - 2000-11-21 08:55:36
|
On Mon, 20 Nov 2000 pyu...@li... wrote: > Hi; the problem is that the __init__ method in TestCase takes a parameter > that is the name of the test method that will be run by the instance. I wonder whether this isn't an aspect of the API that can be improved? Often tests are simpler if they take constructor and then you create a test for each possible combination of what you want to test, ie: from operator import * for _class in (Point, Size): for _op in (mul, div, add, sub): testSuite.add(VectorMathTestCase(_class, _op)) The fact that the tests must inherit from a TestCase base class makes it more difficult to do such things, since the base class has a constructor and semantics that must be maintained. Wouldn't it be better if, instead of test inheriting from TestCase so that you can ask a test: "Hey you! Inspect yourself for test methods and run yourself!", you just hand the test runner an arbitrary class and as *it*: "Here's a class. Inspect it for checkXXX methods and run them". I think the XUnit community has fallen into the trap of thinking that Kent Beck's original SUnit interface (from which PyUnit and all the others derive) is somehow a perfect API that is set in stone. Knowing Beck's Extreme Programming approach, he would not have done "Big Design Up Front" to come up with a perfect test API, but simply did "The Simplest Thing that Could Possibly Work" - but thereafter, as he needed to extend it, keep refactoring it so that it stays simple and clean. I think that: - The SUnit which Kent's group use internally is by now nothing like the original one they published, and - The XUnit community might have got themselves stuck on the "simplest thing that could possibly work", minus the benefit of later refactorings, on the false assumption that they've been handed an API that they may not change. -- ,_ /_) /| / / i e t e r / |/ a g e l |