[Product-Developers] Re: Test setup in ZopeSkel

Ross Patterson me at rpatterson.net
Thu Aug 21 16:17:45 UTC 2008


Daniel Nouri <daniel.nouri at gmail.com>
writes:

> Ross Patterson writes:
>
>> Daniel Nouri writes:
>>> Not going into the TANGLED MESS that Plone test setups have arrived
>>> to, I believe that you'll need to load your ZCML if you depend on
>>> the registrations therein in your test.  That is, AFAIK, noone's
>>> going to implicitely load the site.zcml for you, which is a good
>>> thing.
>>>
>>> And yes, being able to run the tests independently of the specific
>>> buildout you're using it with is quite a feature.
>>
>> The PloneSite layer depends on the ZCML layer which does indeed load
>> site.zcml.  So if the ZCML your test fixture requires is included by
>> loading site.zcml for the instance and you're using the layer
>> PloneSite (which PloneTestCase does), then you don't need to load it
>> explicitly in your test fixture.  At least that's my understanding.
>> :)
>
> Ugh.  If that's so, I call it broken.

Yeah, I've always thought so.  Of course one problem with doing away
with it that fact that a lot of tests need ZCML dependencies to be
configured.  I used to use <include> statements to include all the ZCML
my code depended on, but someone informed me this was poor behavior,
that stitching together packages was the job of an app, not of a package
itself and shouldn't be done in tests.  And if I were working in a Z3
world, where components were nicely isolated, that would work great.
The boundaries between the different ZCML would nicely coincide with the
mock-up I needed for my tests.

In my experience, however, the assumption of isolation simply isn't true
in most of my real world Plone work excepting the most pure
infrastructure or framework work.  Most of my tests are bastardized
functional tests and it seems like this is widely the case.

Of course this is because ZopeTestCase and PloneTestCase themselves are
much closer to functional test fixtures than unit test fixtures.
Indeed, they would break thoroughly without loading the ZCML from most
of their dependencies.

So maybe the ZCML layer could be changed to explicitly load just the
ZCML that Plone *core* itself depends on.  IOW, just enough ZCML for PTC
to work.  This seems like a nice incremental step forward.  It
eliminates the magic of your package's ZCML being included for all tests
that happen to use the PloneSite layer just because your buildout
includes your package in site.zcml.  But it preserves the functional
behavior of loading all the ZCML required by Plone.  This, however,
would be a very disruptive change, since many tests in the wild
unwittingly depend on site.zcml being loaded and would break with
minimal explanation.

>> BTW, I'm very much in favor of reducing the boilerplate in ZopeSkel,
>> particularly the testing boilerplate.  Here's the boilerplate I use
>> for a testing.py module:
>
> I like this.  Anyone against using it for our ZopeSkel templates?

I'm for it!  :)

Ross





More information about the Product-Developers mailing list