On 15/08/06, Collin Winter <[EMAIL PROTECTED]> wrote:
On 8/15/06, Ovid <[EMAIL PROTECTED]> wrote:
> ----- Original Message ----
> From: Fergal Daly <[EMAIL PROTECTED]>
>
> > XUnit allows heirarchical grouping, TAP does not. DUnit (Delphi's
> > XUnit) comes with a GUI that shows you a tree of tests/groups,
>
> This is the sort of input that other's outside of the Perl community might be 
able to
> give due to their being familiar with the ins and outs of it.

Python's unittest (a derivative of JUnit) allows you to group related
tests (each test case is a method on a class) and then combine these
groups (via multiple inheritance). However, once composed, the methods
inherited from the parent classes appear in the test output as if they
had been defined on the child class directly. A quick illustration:

>>> class TestLength(unittest.TestCase):
>>>     def test_empty(test):
>>>         test.assertEqual(len(test.empty), 0)
>>>
>>>     # Some other common len()-based tests
>>>
>>> class TestDict(TestLength):
>>>     def setUp(test):
>>>         test.empty = dict()
>>>
>>>     # Some other tests for dict()
>>>
>>> class TestList(TestLength):
>>>   def setUp(test);
>>>         test.empty = list()
>>>
>>>     # Some other tests for list()

When TestDict and TestList were run, they would both run a
test_empty() method; in the standard text output mode, this would show
up as TestDict.test_empty() and TestList.test_empty(), respectively.

I'm actualy talking about TestSuite objects. Here's some Python

import unittest

class ATest(unittest.TestCase):
 def testFooBar(self):
   self.assertEquals(foo(), bar())

 def testOther(self):
   ...

class AnotherTest(unittest.TestCase):
 def testBuz(self):
   ...

suite1 = unittest.TestSuite()
suite2.addTests(ATest, AnotherTest)

suite2 = unittest.TestSuite()
suit2.addTests(...)

all_suites = unittest.TestSuite()
all_suites.addTest(suite1, suite2, SomeOtherTest)

all_suites.run()


So all_suites is a TestSuite containing 2 other suites and a test,
both of the suites contain other tests.

So the structure is like this:

all_suites
 suite1
   ATest
     testFooBar
     testOther
   AnotherTest
     testBuz
 suite2
   ...
 SomeOtherTest
   ...

TAP cannot represent this nested structure.

Just as an aside, allowing this kind of nested structure (with nested
plans) solves many of the plan problems that have been brought up
recently. Last time I brought it up I was told YAGNI but if you want
TAP to be used for XUnit then you are going to need it,

F



All that to say: there'd be no problem integrating a TAP emitter as an
extension to Python's common testing framework. In fact, coding up
such a thing has been on my todo list for a week or two now.

Collin Winter

Reply via email to