TestInitialize and Test Cleanup routines in Pex RRS feed

  • Question

  • Hi,
    We have a task of converting existing conventional unit test cases of Microsoft Data Access Application Blocks to Parameterized Unit Test cases using Pex.  There are lots of instances where we have Setup and Teardown methods in the given conventional unit test cases.   These methods get automatically called before and after execution of each test cases.  However, when we annotate a TestMethod to PexMethod, these routines does not get called automatically.  And we are manually calling these setup and teardown methods in the PexMethod.  Is there a better way to do this?

    Sunday, November 1, 2009 5:34 PM


  • Which unit test framework are you using?
    Can you give a small, self-contained example where it doesn't work?

    It is true that in general, we do not encourage the use of such setup and teardown methods with Pex, but they should work in most scenarios.

    With MSTest, methods marked with [TestInitialize] and [TestCleanup] should get executed before and after each individual test run that Pex does, possibly many on a parameterized unit test.

    Nikolai Tillmann - Tell us how you use Pex
    Tuesday, November 3, 2009 1:35 AM