How to skip the teardown section in Gallio/MbUnit from a test case
I'm using Gallio/MbUnit with WatiN and I have a defined method to executes as TearDown, what I need is a way to ski开发者_运维问答p the TearDown from a specific Test Case, is that possible?
Thanks.
I don't believe there is a way to skip the TearDown method for a particular test method. I ran into a similar need with MBUnit, so what I did instead, was removed the SetUp and TearDown methods. I then created a factory class that would do the needed SetUp/Teardown for me utilizing a "using" statement. Example:
[Test]
public void Folder_GetPropertyType_Valid()
{
using (var folder = IntegrationUtil.GetFolder())
{
PropId pid = folder.Properties.ElementAt(FolderMockConstants.FOLDER_FIRST_ELEMENT);
Assert.AreEqual(FolderMockConstants.FOLDER_VALID_PROPERTY_TYPE, folder.GetPropertyType(pid));
}
}
In this case, I use the factory IntegrationUtil to get an object instance of a folder, and things get cleaned up after the "using" brackets. This test was pulled out of an MBUnit test class which did not have any Setup/TearDown methods included.
Hope this helps.
精彩评论