The approach you're using with the ObjectFixtureAttribute
doesn't quite work for me unfortunately because I want to apply customized setup
and teardown steps around what the TestFixtureAttribute already
defines.
I can't think of a way to achieve this within MbUnit as it
stands because TestFixturePatternAttributes cannot interact with one
another. Each is pretty much a black box. Arguably that's a good
thing. Currently there's no way to decorate abitrary fixtures with new
behavior by tacking on some attribute.
I'm trying to imagine a way that several components could
contribute to the construction of a common test fixture. It's a little
tricky. I think we'd need to define a common data model for the test
lifecycle. Components could add in the various bits needed
to manage their contributions. For instance, a TypeFixture needs to
weave in support for manufacturing an instance of a type
and passing it in as the first argument to each test
method. There's no reason it shouldn't be able to work with
RowTests. TypeFixture and RowTest would both contribute to a common model
for the test's parameters. Of course there can certainly be conflicting
usages.
Anyways, just for now I've defined a
TestFixtureExtensionAttribute that can contribute tests and setup/teardown logic
to a TestFixture. I've attached the patch. Please let me know what
you think.
Cheers,
Jeff.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jay Flowers
Sent: Friday, July 28, 2006 5:34 AM
To: [EMAIL PROTECTED]
Cc: [email protected]
Subject: MbUnit Re: Extending TestFixtureAttribute.
On 7/27/06, Jeff
Brown <[EMAIL PROTECTED]>
wrote:
I want to define some new kinds of tests (ala RowTest) for a TestFixture
that cannot be handled by test decorators because I want to bind values
to test method parameters in a different way. Unfortunately the design
of TestFixtureAttribute forbids it.
Right now I just need the TestFixtureAttribute to not be sealed so that
I can extend it, or the TestRun, RowRun and CombinatorialRun classes to
not be internal so I can re-use them.
For those who are interested, I'm working on a simpler data-driven test
mechanism for our Quality Engineering group that does not require as
much boilerplate as the built-in MbUnit stuff. Also because QE is using
MbUnit to automate system tests they are exposed to environmental
dependencies I want to factor out into configuration files or in-line
configuration data. (This is not a problem for most of our unit tests
of course because we can use mocks and other tricks.)
A typical test looks something like the following. Notice the RowTest
pattern at work here.
[DataTest]
[DevData("foo", "bar")] // used for development environment
[LiveData("baz", "blah")] // used for production environment
public void SignIn(string username, string password)
{
}
But data can be sourced from a file also.
[DataTest]
[DevDataSource("credentials.dev.xml")]
[LiveDataSource("credentials.live.xml ")]
public void SignIn(string username, string password)
{
}
For data-driven tests (and combinatorial variants thereof) I've started
to think of a more general pattern for binding values to test method
parameters and test fixture properties. Really, that's most of what the
TypeFixture and other MbUnit goodies are accomplishing. However because
MbUnit is not using a common extensible mechanism to achieve this
binding, we cannot mix-and-match test attributes from different types of
fixtures.
Phil's recent question is an example of this problem because he's
finding he cannot use TypeFixture and RowTest together.
For v3, I think we should try to make test data binding orthogonal with
respect to test execution. I have a few ideas about how we might
implement such a notion.
Jeff.
http://jayflowers.com
---------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
TestFixtureExtension.diff
Description: TestFixtureExtension.diff
- MbUnit Re: Extending TestFixtureAttribute. Jeff Brown
- MbUnit Re: Extending TestFixtureAttribute. Jeff Brown
- MbUnit Re: Extending TestFixtureAttribute. Andrew Stopford
