It's possible...

What you can do is to implement a subclass of
TestFixtureExtensionAttribute and apply it to the fixture.  You can
inject additional behavior before setup and after teardown so in
principle you can wrap the "whole process".  Let me know if that helps.

Out of curiosity, what does your decorator do?  Do you believe it would
be of value to others in the community?  If so, I'd like to hear about
it so we can consider it for MbUnit Gallio.

Cheers,
Jeff. 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
On Behalf Of Seth A. Roby
Sent: Tuesday, August 28, 2007 3:35 PM
To: MbUnit.User
Subject: MbUnit DecoratorPatternAttribute


I have a few DecoratorPatternAttribute subclasses defined, but they
don't work quite the way I thought they did.

If I've got a fixture with a setup, the test itself, and a teardown, the
flow looks like this:
    1. SetUp
    2. MyTest
    3. TearDown

I thought the DecoratorPatternAttribute would provide the Invoker, and
that Invoker would wrap the entire process. Note that I don't want it to
wrap the FIXTURE, just the single test's SetUp/Test/TearDown, as
so:
    1. MyInvoker.Execute begins, calls its Invoker.Execute which leads
to 2-4
    2. SetUp
    3. MyTest
    4. TearDown
    5. The internal call to Invoker.Execute from Step 1 ends, and
MyInvoker.Execute completes its work.

But what really happens is that a new Invoker is created for each step.
    1. MyInvoker.Execute begins, calls its Invoker.Execute which leads
to 2 ONLY
    2. SetUp
    3. The internal call to Invoker.Execute from Step 1 ends, and
MyInvoker.Execute completes its work.
    4. MyInvoker.Execute begins, calls its Invoker.Execute which leads
to 5 ONLY
    5. MyTest
    6. The internal call to Invoker.Execute from Step 4 ends, and
MyInvoker.Execute completes its work.
    7. MyInvoker.Execute begins, calls its Invoker.Execute which leads
to 8 ONLY
    8. TearDown
    9. The internal call to Invoker.Execute ends from Step 7, and
MyInvoker.Execute completes its work.

This makes a lot of use cases impossible:
    - I can't set up some external resource in my Attribute, modify it's
behavior in the SetUp, and then use it in the Test, because by the time
the Test rolls around the Attribute has fired again, and the SetUp steps
are overridden by the new Attribute.
    - I can't modify the resource in SetUp and TearDown the resulting
object, because in TearDown it's a new Attribute that doesn't know any
of the changes that occured in SetUp. So if I had a cache of files on
disk, I can't change that location in SetUp, or I'd leak those files.

If the Invoker was the same one every time I could keep track of it that
way, but it's a new instance each time, so no dice.

How would I go about making the "wrap the whole process" decorator I
want? Is it possible using some other class, or do I have to involve
myself with the IRun interface and it's ilk (which I haven't needed to
deal with yet)?




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/MbUnitUser?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to