In practice I have found that using fancy featureful abstract test classes that are partially overridden or suppressed can produce extremely convoluted behaviour.
So in this case I recommend that you explore the idea of implementing configurable contract verifiers that construct just the necessary tests in the right way based on available type information and user-specified properties. Jeff. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Mark Kharitonov Sent: Sunday, August 23, 2009 7:41 AM To: MbUnit.User Subject: MbUnit Re: Can derived type suppress tests inherited from a base type? I see, alas, it is not good enough for my scenario. I would like to suppress tests at run-time based on their metadata.This way the dummy entities test type could be the base type for real entity test type with an auxiliary type in the middle, which eliminates the need to generate the test case dynamically. The auxiliary type could reflect on the inherited test cases and at run-time suppress those not compatible with the particular real entity. That suppression could be performed based on two sets of metadata: * A test case may be decorated with a metadata indicating the entity feature required for this test even to be relevant. * A real entity type can be associated with the metadata indicating the features it supports or does not support. (In my framework, a real entity type is associated with a unit test context type dedicated to serving the particular entity. That context knows to tell whether the entity supports the particular feature). The described scheme makes dynamic test generation unnecessary, because the tests are inherited, while an inheritor may dynamically suppress some test cases. Anyway, because it is not possible, I am doing it through the dynamic test creation, while making sure only the relevant tests are created. I still have to devote some time to trying out the contracts approach... On Aug 22, 10:39 pm, "Jeff Brown" <[email protected]> wrote: > This is not really supported but it can be emulated. > > public class A > { > [Test] > public virtual void Test() > { > ... > } > > } > > public class B : A > { > [Ignore] > public override void Test() > { > } > > } > > Of course instead of using [Ignore] we could introduce some kind of > do-nothing [NotATest] attribute. > > Jeff. > > -----Original Message----- > From: [email protected] [mailto:[email protected]] > On > > Behalf Of Mark Kharitonov > Sent: Saturday, August 22, 2009 10:31 AM > To: MbUnit.User > Subject: MbUnit Can derived type suppress tests inherited from a base type? > > Hi. > > Imagine two types - a test fixture type and a derived one. So, the > derived type inherits the tests from the base type. > Can the derived type instruct the unit test framework to suppress a > few tests inherited from the base type? So that a test A is enabled in > the base type, but disabled in the derived one? > > Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
